diff --git a/barker/barker/models/guest_book.py b/barker/barker/models/guest_book.py
index 9194f0e..efbf4f6 100644
--- a/barker/barker/models/guest_book.py
+++ b/barker/barker/models/guest_book.py
@@ -30,11 +30,11 @@ class GuestBook:
customer: Mapped["Customer"] = relationship("Customer")
status: Mapped[Optional["Overview"]] = relationship(back_populates="guest", uselist=False)
- def __init__(self, pax=None, id_=None, customer_id=None, customer=None):
+ def __init__(self, pax=None, id_=None, customer_id=None, customer=None, date_=None):
self.customer_id = customer_id
self.pax = pax
self.id = id_
- self.date = datetime.utcnow()
+ self.date = datetime.utcnow() if date_ is None else date_
if customer is None:
self.customer_id = customer_id
else:
diff --git a/barker/barker/routers/guest_book.py b/barker/barker/routers/guest_book.py
index 1a6e064..a5fedbd 100644
--- a/barker/barker/routers/guest_book.py
+++ b/barker/barker/routers/guest_book.py
@@ -38,7 +38,9 @@ def save(
else:
customer.name = data.name or customer.name
customer.address = data.address or customer.address
- item = GuestBook(pax=data.pax, customer=customer)
+ item = GuestBook(
+ pax=data.pax, customer=customer, date_=data.date_ - timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)
+ )
db.add(item)
db.commit()
return guest_book_info(item)
@@ -62,6 +64,7 @@ def update_route(
item.customer.phone = data.phone
item.customer.address = data.address
item.pax = data.pax
+ item.date = data.date_ - timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)
db.commit()
return guest_book_info(item)
except SQLAlchemyError as e:
@@ -159,9 +162,15 @@ def guest_book_info(item: GuestBook) -> schemas.GuestBook:
phone=item.customer.phone,
pax=item.pax,
address=item.customer.address,
- date=item.date,
+ date=item.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES),
)
def blank_guest_book_info() -> schemas.GuestBookIn:
- return schemas.GuestBookIn(name="", phone="", pax=0, address="")
+ return schemas.GuestBookIn(
+ name="",
+ phone="",
+ pax=0,
+ address="",
+ date=datetime.utcnow() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES),
+ )
diff --git a/barker/barker/routers/voucher/show.py b/barker/barker/routers/voucher/show.py
index 2421840..dc3fd34 100644
--- a/barker/barker/routers/voucher/show.py
+++ b/barker/barker/routers/voucher/show.py
@@ -147,7 +147,7 @@ def voucher_info(item: Voucher, db: Session):
"kotId": item.kot_id,
"billId": ", ".join(f"{x.regime.prefix}-{x.bill_number}" for x in item.bills),
"table": {"id": item.food_table_id, "name": item.food_table.name},
- "customer": {"id": item.customer_id, "name": item.customer.name} if item.customer is not None else None,
+ "customer": {"id": item.customer.id, "name": item.customer.name} if item.customer is not None else None,
"narration": item.narration,
"reason": item.reason,
"voucherType": item.voucher_type,
diff --git a/barker/barker/schemas/guest_book.py b/barker/barker/schemas/guest_book.py
index 40b02c4..8855d2f 100644
--- a/barker/barker/schemas/guest_book.py
+++ b/barker/barker/schemas/guest_book.py
@@ -12,16 +12,23 @@ class GuestBookIn(BaseModel):
phone: str
address: str | None
pax: int = Field(ge=0)
+ date_: datetime
+
+ @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")}
class GuestBook(GuestBookIn):
id_: uuid.UUID
- date_: datetime
@validator("date_", pre=True)
def parse_date(cls, value):
diff --git a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html
index 554b932..bf64cac 100644
--- a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html
+++ b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html
@@ -39,6 +39,16 @@
+
+
+ Hours
+
+
+
+ Minutes
+
+
+
diff --git a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts
index 39d356e..e21698d 100644
--- a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts
+++ b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts
@@ -23,6 +23,8 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
phone: FormControl;
pax: FormControl;
address: FormControl;
+ hours: FormControl;
+ minutes: FormControl;
}>;
item: GuestBook = new GuestBook();
@@ -44,6 +46,8 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
}),
pax: new FormControl(0, { validators: Validators.required, nonNullable: true }),
address: new FormControl(null),
+ hours: new FormControl(0, { validators: [Validators.min(0), Validators.max(23)], nonNullable: true }),
+ minutes: new FormControl(0, { validators: [Validators.min(0), Validators.max(59)], nonNullable: true }),
});
// Setup Account Autocomplete
this.customers = this.form.controls.phone.valueChanges.pipe(
@@ -77,6 +81,8 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
phone: item.phone,
pax: item.pax,
address: item.address,
+ hours: +item.date.substring(12, 14),
+ minutes: +item.date.substring(15, 17),
});
}
@@ -115,6 +121,9 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
}
this.item.pax = formModel.pax ?? 0;
this.item.address = formModel.address ?? null;
+ const hours = ('' + (formModel.hours as number)).padStart(2, '0');
+ const minutes = ('' + (formModel.minutes as number)).padStart(2, '0');
+ this.item.date = this.item.date.substring(0, 12) + hours + ':' + minutes;
return this.item;
}
}
diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.css b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.css
deleted file mode 100644
index a335237..0000000
--- a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.css
+++ /dev/null
@@ -1,17 +0,0 @@
-.full-width-table {
- width: 100%;
-}
-
-.running {
- background-color: #f53d24;
- color: #000000;
-}
-
-.printed {
- background-color: #00f518;
- color: #000000;
-}
-.center {
- display: flex;
- justify-content: center;
-}
diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html
index 6517515..e5dada4 100644
--- a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html
+++ b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html
@@ -23,7 +23,7 @@
S. No
- {{ row.serial }} {{ row.status }}
+ {{ row.serial }}
@@ -78,8 +78,8 @@
diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.sass b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.sass
new file mode 100644
index 0000000..ab956a3
--- /dev/null
+++ b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.sass
@@ -0,0 +1,21 @@
+@use '@angular/material' as mat
+
+$my-primary: mat.define-palette(mat.$indigo-palette, 500)
+$my-accent: mat.define-palette(mat.$amber-palette, A200, A100, A400)
+
+table
+ width: 100%
+
+.center
+ display: flex
+ justify-content: center
+
+.accent
+ /* Read the 200 hue from the primary color palete.*/
+ color: mat.get-color-from-palette($my-accent, '200-contrast')
+ background: mat.get-color-from-palette($my-accent, 200)
+
+.strong-accent
+ /* Read the 700 hue from the primary color palete.*/
+ color: mat.get-color-from-palette($my-accent, '700-contrast')
+ background: mat.get-color-from-palette($my-accent, 700)
diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts
index 87b5971..52473a3 100644
--- a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts
+++ b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts
@@ -17,7 +17,7 @@ import { GuestBookListDataSource } from './guest-book-list-datasource';
@Component({
selector: 'app-guest-book-list',
templateUrl: './guest-book-list.component.html',
- styleUrls: ['./guest-book-list.component.css'],
+ styleUrls: ['./guest-book-list.component.sass'],
})
export class GuestBookListComponent implements OnInit {
data: BehaviorSubject = new BehaviorSubject([]);