diff --git a/brewman/routers/reports/unposted.py b/brewman/routers/reports/unposted.py
index fb058855..d1bf3b16 100644
--- a/brewman/routers/reports/unposted.py
+++ b/brewman/routers/reports/unposted.py
@@ -1,3 +1,5 @@
+from typing import List
+
from fastapi import APIRouter, Depends, Security, Request
from sqlalchemy.orm import joinedload_all, Session
@@ -5,6 +7,7 @@ from ...schemas.auth import UserToken
from ...core.security import get_current_active_user as get_user
from ...db.session import SessionLocal
from brewman.models.voucher import Voucher, Journal, VoucherType
+import brewman.schemas.reports as schemas
router = APIRouter()
@@ -18,7 +21,7 @@ def get_db() -> Session:
db.close()
-@router.get("")
+@router.get("", response_model=List[schemas.Unposted])
def report_data(
request: Request,
db: Session = Depends(get_db),
@@ -59,7 +62,8 @@ def build_report(db: Session):
{
"id": voucher.id,
"date": voucher.date.strftime("%d-%b-%Y"),
- "voucherType": VoucherType.by_id(voucher.type).name,
+ "url": ['/', VoucherType.by_id(voucher.type).name.replace(" ", "-").lower(), str(voucher.id)],
+ "type": VoucherType.by_id(voucher.type).name,
"narration": voucher.narration,
"debitName": name_debit,
"debitAmount": debit,
diff --git a/brewman/schemas/reports.py b/brewman/schemas/reports.py
index cf34d1c3..cfb06f1d 100644
--- a/brewman/schemas/reports.py
+++ b/brewman/schemas/reports.py
@@ -478,3 +478,26 @@ class TrialBalance(BaseModel):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
+
+
+class Unposted(BaseModel):
+ id_: uuid.UUID
+ date_: date
+ url: List[str]
+ type_: str
+ narration: str
+ debit_name: str
+ debit_amount: Decimal
+ credit_name: str
+ credit_amount: Decimal
+
+ @validator("date_", pre=True)
+ def parse_date(cls, value):
+ if isinstance(value, date):
+ return value
+ return datetime.strptime(value, "%d-%b-%Y").date()
+
+ class Config:
+ anystr_strip_whitespace = True
+ alias_generator = to_camel
+ json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
diff --git a/overlord/src/app/unposted/unposted.component.html b/overlord/src/app/unposted/unposted.component.html
index 58430c99..a36432f9 100644
--- a/overlord/src/app/unposted/unposted.component.html
+++ b/overlord/src/app/unposted/unposted.component.html
@@ -12,13 +12,13 @@
Date
- {{row.date}}
+ {{row.date}}
Type
- {{row.voucherType}}
+ {{row.type}}
diff --git a/overlord/src/app/unposted/unposted.component.ts b/overlord/src/app/unposted/unposted.component.ts
index 8dcd8af8..f2bb8858 100644
--- a/overlord/src/app/unposted/unposted.component.ts
+++ b/overlord/src/app/unposted/unposted.component.ts
@@ -24,12 +24,7 @@ export class UnpostedComponent implements OnInit {
}
ngOnInit() {
- this.route.data.pipe(map(
- (data: { info: Unposted[] }) => {
- data.info = data.info.map(x => ({...x, url: x['type'].replace(/ /g, '-').toLowerCase()}));
- return data;
- }
- )).subscribe((data: { info: Unposted[] }) => {
+ this.route.data.subscribe((data: { info: Unposted[] }) => {
this.info = data.info;
});
this.dataSource = new UnpostedDataSource(this.paginator, this.sort, this.info);
diff --git a/overlord/src/app/unposted/unposted.ts b/overlord/src/app/unposted/unposted.ts
index 0a992013..286f64f9 100644
--- a/overlord/src/app/unposted/unposted.ts
+++ b/overlord/src/app/unposted/unposted.ts
@@ -1,7 +1,8 @@
export class Unposted {
id: string;
date: string;
- voucherType: string;
+ url: string[];
+ type: string;
narration: string;
debitName: string;
debitAmount: number;