Fix: Dates in old imported data should be at UTC time.
Fix: Use utc now for dates to have consistent dates across timezones.
This commit is contained in:
parent
823808d402
commit
07d13898c3
|
@ -14,12 +14,12 @@ call:copyQuery l-Modifiers "SELECT ModifierID, Name, CASE WHEN ShowInBill = 1 TH
|
||||||
call:copyQuery m-Sections "SELECT NewID(), Location, 'f' FROM Test.dbo.PrintLocations GROUP BY Location;"
|
call:copyQuery m-Sections "SELECT NewID(), Location, 'f' FROM Test.dbo.PrintLocations GROUP BY Location;"
|
||||||
call:copyQuery n-Printers "SELECT NewID(), Printer, Printer, 0x1d564103 FROM Test.dbo.PrintLocations GROUP BY Printer, CutCode;"
|
call:copyQuery n-Printers "SELECT NewID(), Printer, Printer, 0x1d564103 FROM Test.dbo.PrintLocations GROUP BY Printer, CutCode;"
|
||||||
call:copyQuery o-SectionPrinters "SELECT PrintLocationID, COALESCE(CAST(ProductGroupID AS Nvarchar(36)), '\N'), Location, Printer, Copies FROM Test.dbo.PrintLocations;"
|
call:copyQuery o-SectionPrinters "SELECT PrintLocationID, COALESCE(CAST(ProductGroupID AS Nvarchar(36)), '\N'), Location, Printer, Copies FROM Test.dbo.PrintLocations;"
|
||||||
call:copyQuery p-Vouchers "SELECT VoucherID, Date, Pax, UserID, CreationDate, LastEditDate, COALESCE(CAST(BillID AS Nvarchar(36)), '\N'), TableID, CustomerID, COALESCE(Narration, '\N'), VoidReason, CASE WHEN Printed = 0 THEN '0' WHEN Void = 1 THEN '5' ELSE VoucherType END, KotID FROM Test.dbo.Vouchers;"
|
call:copyQuery p-Vouchers "SELECT VoucherID, DATEADD(minute, -330, Date), Pax, UserID, DATEADD(minute, -330, CreationDate), DATEADD(minute, -330, LastEditDate), COALESCE(CAST(BillID AS Nvarchar(36)), '\N'), TableID, CustomerID, COALESCE(Narration, '\N'), VoidReason, CASE WHEN Printed = 0 THEN '0' WHEN Void = 1 THEN '5' ELSE VoucherType END, KotID FROM Test.dbo.Vouchers;"
|
||||||
call:copyQuery q-Kots "SELECT KotID, VoucherID, Code, TableID, Date, UserID FROM Test.dbo.Kots;"
|
call:copyQuery q-Kots "SELECT KotID, VoucherID, Code, TableID, DATEADD(minute, -330, Date), UserID FROM Test.dbo.Kots;"
|
||||||
call:copyQuery r-Inventories "SELECT InventoryID, KotID, ProductID, SortOrder, Quantity, Price, CASE WHEN IsHappyHour = 1 THEN 't' ELSE 'f' END, VatRate, VatID, Discount FROM Test.dbo.Inventories;"
|
call:copyQuery r-Inventories "SELECT InventoryID, KotID, ProductID, SortOrder, Quantity, Price, CASE WHEN IsHappyHour = 1 THEN 't' ELSE 'f' END, VatRate, VatID, Discount FROM Test.dbo.Inventories;"
|
||||||
call:copyQuery s-InventoryModifiers "SELECT InventoryModifierID, InventoryID, ModifierID, 0 FROM Test.dbo.InventoryModifiers;"
|
call:copyQuery s-InventoryModifiers "SELECT InventoryModifierID, InventoryID, ModifierID, 0 FROM Test.dbo.InventoryModifiers;"
|
||||||
call:copyQuery t-Overview "SELECT newid(), VoucherID, FoodTableID, Status FROM Test.dbo.FoodTables WHERE VoucherID IS NOT NULL;"
|
call:copyQuery t-Overview "SELECT newid(), VoucherID, FoodTableID, Status FROM Test.dbo.FoodTables WHERE VoucherID IS NOT NULL;"
|
||||||
call:copyQuery u-Reprints "SELECT ReprintID, UserID, Date, VoucherID FROM Test.dbo.Reprints;"
|
call:copyQuery u-Reprints "SELECT ReprintID, UserID, DATEADD(minute, -330, Date), VoucherID FROM Test.dbo.Reprints;"
|
||||||
call:copyQuery v-Settings "SELECT SettingID, Name, '{""Text"": ""' + Details + '""}' FROM Test.dbo.Settings;"
|
call:copyQuery v-Settings "SELECT SettingID, Name, '{""Text"": ""' + Details + '""}' FROM Test.dbo.Settings;"
|
||||||
call:copyQuery w-VoucherSettlements "SELECT VoucherSettlementID, VoucherID, Settled, Amount FROM Test.dbo.VoucherSettlements;"
|
call:copyQuery w-VoucherSettlements "SELECT VoucherSettlementID, VoucherID, Settled, Amount FROM Test.dbo.VoucherSettlements;"
|
||||||
goto:eof
|
goto:eof
|
||||||
|
|
|
@ -28,6 +28,6 @@ class Reprint(Base):
|
||||||
|
|
||||||
def __init__(self, voucher_id=None, user_id=None, id_=None):
|
def __init__(self, voucher_id=None, user_id=None, id_=None):
|
||||||
self.id = id_
|
self.id = id_
|
||||||
self.date = datetime.now()
|
self.date = datetime.utcnow()
|
||||||
self.voucher_id = voucher_id
|
self.voucher_id = voucher_id
|
||||||
self.user_id = user_id
|
self.user_id = user_id
|
||||||
|
|
|
@ -14,7 +14,9 @@ def optional_query_date(d: str = None) -> Optional[date]:
|
||||||
|
|
||||||
def effective_date(d: str = None) -> date:
|
def effective_date(d: str = None) -> date:
|
||||||
return (
|
return (
|
||||||
(datetime.now() - timedelta(minutes=settings.NEW_DAY_OFFSET_MINUTES)).date()
|
(
|
||||||
|
datetime.utcnow() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES)
|
||||||
|
).date()
|
||||||
if d is None
|
if d is None
|
||||||
else datetime.strptime(d, "%d-%b-%Y").date()
|
else datetime.strptime(d, "%d-%b-%Y").date()
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime, timedelta
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from barker.core.config import settings
|
||||||
|
from fastapi import HTTPException, status
|
||||||
|
|
||||||
|
|
||||||
def report_start_date(s: str = None) -> date:
|
def report_start_date(s: str = None) -> date:
|
||||||
|
@ -7,3 +11,12 @@ def report_start_date(s: str = None) -> date:
|
||||||
|
|
||||||
def report_finish_date(f: str = None) -> date:
|
def report_finish_date(f: str = None) -> date:
|
||||||
return date.today() if f is None else datetime.strptime(f, "%d-%b-%Y").date()
|
return date.today() if f is None else datetime.strptime(f, "%d-%b-%Y").date()
|
||||||
|
|
||||||
|
|
||||||
|
def check_audit_permission(start_date: date, user_permissions: List[str]):
|
||||||
|
today = (datetime.utcnow() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
||||||
|
if (today - start_date).days > 5 and "audit" not in user_permissions:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
from operator import or_
|
from operator import or_
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
from fastapi import APIRouter, Depends, Security
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from sqlalchemy.sql.expression import func
|
from sqlalchemy.sql.expression import func
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from ...models.product_version import ProductVersion
|
||||||
from ...models.voucher import Voucher
|
from ...models.voucher import Voucher
|
||||||
from ...models.voucher_type import VoucherType
|
from ...models.voucher_type import VoucherType
|
||||||
from ...schemas.user_token import UserToken
|
from ...schemas.user_token import UserToken
|
||||||
from . import report_finish_date, report_start_date
|
from . import check_audit_permission, report_finish_date, report_start_date
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
@ -36,12 +36,7 @@ def beer_consumption(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["beer-sale-report"]),
|
user: UserToken = Security(get_user, scopes=["beer-sale-report"]),
|
||||||
):
|
):
|
||||||
if (date.today() - start_date).days > 5 and "audit" not in user.permissions:
|
check_audit_permission(start_date, user.permissions)
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
|
|
||||||
day = func.date_trunc("day", Voucher.date - timedelta(minutes=settings.NEW_DAY_OFFSET_MINUTES)).label("day")
|
day = func.date_trunc("day", Voucher.date - timedelta(minutes=settings.NEW_DAY_OFFSET_MINUTES)).label("day")
|
||||||
sum_ = func.sum(Inventory.quantity * ProductVersion.quantity).label("sum")
|
sum_ = func.sum(Inventory.quantity * ProductVersion.quantity).label("sum")
|
||||||
list_ = (
|
list_ = (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
from fastapi import APIRouter, Depends, Security
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from ...core.config import settings
|
from ...core.config import settings
|
||||||
|
@ -14,7 +14,7 @@ from ...models.settlement import Settlement
|
||||||
from ...models.voucher import Voucher
|
from ...models.voucher import Voucher
|
||||||
from ...schemas.bill_settlement_report import BillSettlement, BillSettlementItem
|
from ...schemas.bill_settlement_report import BillSettlement, BillSettlementItem
|
||||||
from ...schemas.user_token import UserToken
|
from ...schemas.user_token import UserToken
|
||||||
from . import report_finish_date, report_start_date
|
from . import check_audit_permission, report_finish_date, report_start_date
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
@ -36,12 +36,7 @@ def bill_details(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["bill-settlement-report"]),
|
user: UserToken = Security(get_user, scopes=["bill-settlement-report"]),
|
||||||
) -> BillSettlement:
|
) -> BillSettlement:
|
||||||
if (date.today() - start_date).days > 5 and "audit" not in user.permissions:
|
check_audit_permission(start_date, user.permissions)
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
|
|
||||||
return BillSettlement(
|
return BillSettlement(
|
||||||
startDate=start_date,
|
startDate=start_date,
|
||||||
finishDate=finish_date,
|
finishDate=finish_date,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import uuid
|
||||||
from datetime import date, datetime, time, timedelta
|
from datetime import date, datetime, time, timedelta
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
from fastapi import APIRouter, Cookie, Depends, HTTPException, Security, status
|
from fastapi import APIRouter, Cookie, Depends, Security
|
||||||
from sqlalchemy import distinct
|
from sqlalchemy import distinct
|
||||||
from sqlalchemy.orm import Session, joinedload
|
from sqlalchemy.orm import Session, joinedload
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ from ...schemas.cashier_report import (
|
||||||
)
|
)
|
||||||
from ...schemas.user import UserLink
|
from ...schemas.user import UserLink
|
||||||
from ...schemas.user_token import UserToken
|
from ...schemas.user_token import UserToken
|
||||||
from . import report_finish_date, report_start_date
|
from . import check_audit_permission, report_finish_date, report_start_date
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
@ -45,12 +45,7 @@ def active_cashiers(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
||||||
) -> List[UserLink]:
|
) -> List[UserLink]:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
return get_active_cashiers(start_date, finish_date, db)
|
return get_active_cashiers(start_date, finish_date, db)
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,12 +80,7 @@ def show_id(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
||||||
) -> CashierReport:
|
) -> CashierReport:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
user = UserLink(id=user.id_, name=user.name)
|
user = UserLink(id=user.id_, name=user.name)
|
||||||
return get_id(id_, start_date, finish_date, user, db)
|
return get_id(id_, start_date, finish_date, user, db)
|
||||||
|
|
||||||
|
@ -155,12 +145,7 @@ def print_report(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
||||||
) -> bool:
|
) -> bool:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
report = get_id(id_, start_date, finish_date, UserLink(id=user.id_, name=user.name), db)
|
report = get_id(id_, start_date, finish_date, UserLink(id=user.id_, name=user.name), db)
|
||||||
print_cashier_report(report, device_id, db)
|
print_cashier_report(report, device_id, db)
|
||||||
return True
|
return True
|
||||||
|
@ -173,13 +158,7 @@ def show_blank(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
user: UserToken = Security(get_user, scopes=["cashier-report"]),
|
||||||
) -> CashierReport:
|
) -> CashierReport:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
|
|
||||||
return CashierReport(
|
return CashierReport(
|
||||||
startDate=start_date,
|
startDate=start_date,
|
||||||
finishDate=finish_date,
|
finishDate=finish_date,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import uuid
|
||||||
from datetime import date, datetime, time, timedelta
|
from datetime import date, datetime, time, timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from fastapi import APIRouter, Cookie, Depends, HTTPException, Security, status
|
from fastapi import APIRouter, Cookie, Depends, Security
|
||||||
from sqlalchemy import func, or_
|
from sqlalchemy import func, or_
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ from ...models.voucher_type import VoucherType
|
||||||
from ...printing.discount_report import print_discount_report
|
from ...printing.discount_report import print_discount_report
|
||||||
from ...schemas.discount_report import DiscountReport, DiscountReportItem
|
from ...schemas.discount_report import DiscountReport, DiscountReportItem
|
||||||
from ...schemas.user_token import UserToken
|
from ...schemas.user_token import UserToken
|
||||||
from . import report_finish_date, report_start_date
|
from . import check_audit_permission, report_finish_date, report_start_date
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
@ -41,12 +41,7 @@ def discount_report(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["discount-report"]),
|
user: UserToken = Security(get_user, scopes=["discount-report"]),
|
||||||
) -> DiscountReport:
|
) -> DiscountReport:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
return DiscountReport(
|
return DiscountReport(
|
||||||
startDate=start_date,
|
startDate=start_date,
|
||||||
finishDate=finish_date,
|
finishDate=finish_date,
|
||||||
|
@ -96,12 +91,7 @@ def print_report(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["discount-report"]),
|
user: UserToken = Security(get_user, scopes=["discount-report"]),
|
||||||
) -> bool:
|
) -> bool:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
report = DiscountReport(
|
report = DiscountReport(
|
||||||
startDate=start_date,
|
startDate=start_date,
|
||||||
finishDate=finish_date,
|
finishDate=finish_date,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
from fastapi import APIRouter, Depends, Security
|
||||||
from sqlalchemy import func, or_
|
from sqlalchemy import func, or_
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ from ...models.voucher import Voucher
|
||||||
from ...models.voucher_type import VoucherType
|
from ...models.voucher_type import VoucherType
|
||||||
from ...schemas import to_camel
|
from ...schemas import to_camel
|
||||||
from ...schemas.user_token import UserToken
|
from ...schemas.user_token import UserToken
|
||||||
from . import report_finish_date, report_start_date
|
from . import check_audit_permission, report_finish_date, report_start_date
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
@ -38,12 +38,7 @@ def product_sale_report_view(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["product-sale-report"]),
|
user: UserToken = Security(get_user, scopes=["product-sale-report"]),
|
||||||
):
|
):
|
||||||
if (date.today() - start_date).days > 5 and "audit" not in user.permissions:
|
check_audit_permission(start_date, user.permissions)
|
||||||
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"),
|
||||||
"finishDate": finish_date.strftime("%d-%b-%Y"),
|
"finishDate": finish_date.strftime("%d-%b-%Y"),
|
||||||
|
|
|
@ -3,7 +3,7 @@ import uuid
|
||||||
from datetime import date, datetime, time, timedelta
|
from datetime import date, datetime, time, timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from fastapi import APIRouter, Cookie, Depends, HTTPException, Security, status
|
from fastapi import APIRouter, Cookie, Depends, Security
|
||||||
from sqlalchemy import func, or_
|
from sqlalchemy import func, or_
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ from ...printing.sale_report import print_sale_report
|
||||||
from ...schemas.sale_report import SaleReport, SaleReportItem
|
from ...schemas.sale_report import SaleReport, SaleReportItem
|
||||||
from ...schemas.user import UserLink
|
from ...schemas.user import UserLink
|
||||||
from ...schemas.user_token import UserToken
|
from ...schemas.user_token import UserToken
|
||||||
from . import report_finish_date, report_start_date
|
from . import check_audit_permission, report_finish_date, report_start_date
|
||||||
from .tax_report import get_tax
|
from .tax_report import get_tax
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,13 +45,7 @@ def get_sale_analysis(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["sale-report"]),
|
user: UserToken = Security(get_user, scopes=["sale-report"]),
|
||||||
) -> SaleReport:
|
) -> SaleReport:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
|
|
||||||
return SaleReport(
|
return SaleReport(
|
||||||
startDate=start_date,
|
startDate=start_date,
|
||||||
finishDate=finish_date,
|
finishDate=finish_date,
|
||||||
|
@ -131,12 +125,7 @@ def print_report(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["discount-report"]),
|
user: UserToken = Security(get_user, scopes=["discount-report"]),
|
||||||
) -> bool:
|
) -> bool:
|
||||||
today = (datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date()
|
check_audit_permission(start_date, user.permissions)
|
||||||
if (today - start_date).days > 5 and "audit" not in user.permissions:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
report = SaleReport(
|
report = SaleReport(
|
||||||
startDate=start_date,
|
startDate=start_date,
|
||||||
finishDate=finish_date,
|
finishDate=finish_date,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from datetime import date, timedelta
|
from datetime import date, timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
from fastapi import APIRouter, Depends, Security
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from ...models.voucher import Voucher
|
||||||
from ...models.voucher_type import VoucherType
|
from ...models.voucher_type import VoucherType
|
||||||
from ...schemas.tax_report import TaxReport, TaxReportItem
|
from ...schemas.tax_report import TaxReport, TaxReportItem
|
||||||
from ...schemas.user_token import UserToken
|
from ...schemas.user_token import UserToken
|
||||||
from . import report_finish_date, report_start_date
|
from . import check_audit_permission, report_finish_date, report_start_date
|
||||||
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
@ -37,12 +37,7 @@ def get_tax_report(
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user: UserToken = Security(get_user, scopes=["tax-report"]),
|
user: UserToken = Security(get_user, scopes=["tax-report"]),
|
||||||
) -> TaxReport:
|
) -> TaxReport:
|
||||||
if (date.today() - start_date).days > 5 and "audit" not in user.permissions:
|
check_audit_permission(start_date, user.permissions)
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="Accounts Audit",
|
|
||||||
)
|
|
||||||
|
|
||||||
return TaxReport(
|
return TaxReport(
|
||||||
startDate=start_date.strftime("%d-%b-%Y"),
|
startDate=start_date.strftime("%d-%b-%Y"),
|
||||||
finishDate=finish_date.strftime("%d-%b-%Y"),
|
finishDate=finish_date.strftime("%d-%b-%Y"),
|
||||||
|
|
|
@ -72,7 +72,7 @@ def move_kot(
|
||||||
user: UserToken = Security(get_user, scopes=["move-kot-to-new-table"]),
|
user: UserToken = Security(get_user, scopes=["move-kot-to-new-table"]),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
now = datetime.now()
|
now = datetime.utcnow()
|
||||||
check_if_voucher_is_unprinted(data.voucher_id, db)
|
check_if_voucher_is_unprinted(data.voucher_id, db)
|
||||||
kots: int = db.query(func.count(Kot.id)).filter(Kot.voucher_id == data.voucher_id).scalar()
|
kots: int = db.query(func.count(Kot.id)).filter(Kot.voucher_id == data.voucher_id).scalar()
|
||||||
if kots <= 1:
|
if kots <= 1:
|
||||||
|
|
|
@ -85,7 +85,7 @@ def do_save(
|
||||||
db: Session,
|
db: Session,
|
||||||
user: UserToken,
|
user: UserToken,
|
||||||
):
|
):
|
||||||
now = datetime.now()
|
now = datetime.utcnow()
|
||||||
product_date = (now + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES)).date()
|
product_date = (now + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES)).date()
|
||||||
check_permissions(None, voucher_type, user.permissions)
|
check_permissions(None, voucher_type, user.permissions)
|
||||||
|
|
||||||
|
|
|
@ -154,14 +154,18 @@ def voucher_product(product_id: uuid.UUID, date_: datetime, is_happy_hour: bool,
|
||||||
def voucher_info(item: Voucher, db: Session):
|
def voucher_info(item: Voucher, db: Session):
|
||||||
return {
|
return {
|
||||||
"id": item.id,
|
"id": item.id,
|
||||||
"date": item.date.strftime("%H:%M"),
|
"date": (item.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).strftime("%H:%M"),
|
||||||
"dateTip": item.date.strftime("%d-%b-%Y %H:%M:%S"),
|
"dateTip": (item.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).strftime("%d-%b-%Y %H:%M:%S"),
|
||||||
"pax": item.pax,
|
"pax": item.pax,
|
||||||
"user": {"id": item.user_id, "name": item.user.name},
|
"user": {"id": item.user_id, "name": item.user.name},
|
||||||
"creationDate": item.creation_date.strftime("%H:%M"),
|
"creationDate": (item.creation_date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).strftime("%H:%M"),
|
||||||
"creationDateTip": item.creation_date.strftime("%d-%b-%Y %H:%M:%S"),
|
"creationDateTip": (item.creation_date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).strftime(
|
||||||
"lastEditDate": item.last_edit_date.strftime("%H:%M"),
|
"%d-%b-%Y %H:%M:%S"
|
||||||
"lastEditDateTip": item.last_edit_date.strftime("%d-%b-%Y %H:%M:%S"),
|
),
|
||||||
|
"lastEditDate": (item.last_edit_date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).strftime("%H:%M"),
|
||||||
|
"lastEditDateTip": (item.last_edit_date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).strftime(
|
||||||
|
"%d-%b-%Y %H:%M:%S"
|
||||||
|
),
|
||||||
"kotId": item.kot_id,
|
"kotId": item.kot_id,
|
||||||
"billId": item.full_bill_id,
|
"billId": item.full_bill_id,
|
||||||
"table": {"id": item.food_table_id, "name": item.food_table.name},
|
"table": {"id": item.food_table_id, "name": item.food_table.name},
|
||||||
|
@ -174,7 +178,7 @@ def voucher_info(item: Voucher, db: Session):
|
||||||
{
|
{
|
||||||
"id": k.id,
|
"id": k.id,
|
||||||
"code": k.code,
|
"code": k.code,
|
||||||
"date": k.date.strftime("%d-%b-%Y %H:%M:%S"),
|
"date": (k.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).strftime("%d-%b-%Y %H:%M:%S"),
|
||||||
"user": {"id": k.user_id, "name": k.user.name},
|
"user": {"id": k.user_id, "name": k.user.name},
|
||||||
"inventories": [
|
"inventories": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ def split(
|
||||||
user: UserToken = Security(get_user, scopes=["split-bill"]),
|
user: UserToken = Security(get_user, scopes=["split-bill"]),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
now = datetime.now()
|
now = datetime.utcnow()
|
||||||
update_table = u
|
update_table = u
|
||||||
item: Voucher = db.query(Voucher).filter(Voucher.id == id_).first()
|
item: Voucher = db.query(Voucher).filter(Voucher.id == id_).first()
|
||||||
item.bill_id = None
|
item.bill_id = None
|
||||||
|
|
|
@ -58,7 +58,7 @@ def update(
|
||||||
user: UserToken = Security(get_user),
|
user: UserToken = Security(get_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
now = datetime.now()
|
now = datetime.utcnow()
|
||||||
product_date = (
|
product_date = (
|
||||||
now + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES)
|
now + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES)
|
||||||
).date()
|
).date()
|
||||||
|
|
|
@ -27,12 +27,12 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="time-details">
|
<ng-container matColumnDef="time-details">
|
||||||
<mat-header-cell *matHeaderCellDef class="deep-purple-100 bold right-align"
|
<mat-header-cell *matHeaderCellDef class="deep-purple-100 bold right-align"
|
||||||
><span [matTooltip]="bs.bill.dateTip | localTime">{{ bs.bill.date | localTime }}</span
|
><span [matTooltip]="bs.bill.dateTip">{{ bs.bill.date }}</span
|
||||||
> / <span [matTooltip]="bs.bill.creationDateTip | localTime">{{
|
> / <span [matTooltip]="bs.bill.creationDateTip">{{
|
||||||
bs.bill.creationDate | localTime
|
bs.bill.creationDate
|
||||||
}}</span
|
}}</span
|
||||||
> / <span [matTooltip]="bs.bill.lastEditDateTip | localTime">{{
|
> / <span [matTooltip]="bs.bill.lastEditDateTip">{{
|
||||||
bs.bill.lastEditDate | localTime
|
bs.bill.lastEditDate
|
||||||
}}</span></mat-header-cell
|
}}</span></mat-header-cell
|
||||||
>
|
>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
Loading…
Reference in New Issue