Unposted Done!!
This commit is contained in:
parent
0df442e541
commit
0a79b1acbb
brewman
overlord/src/app/unposted
@ -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,
|
||||
|
@ -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")}
|
||||
|
@ -12,13 +12,13 @@
|
||||
<!-- Date Column -->
|
||||
<ng-container matColumnDef="date">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Date</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/', row.url, row.id]">{{row.date}}</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="row.url">{{row.date}}</a></mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Type Column -->
|
||||
<ng-container matColumnDef="voucherType">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Type</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.voucherType}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.type}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Narration Column -->
|
||||
|
@ -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);
|
||||
|
@ -1,7 +1,8 @@
|
||||
export class Unposted {
|
||||
id: string;
|
||||
date: string;
|
||||
voucherType: string;
|
||||
url: string[];
|
||||
type: string;
|
||||
narration: string;
|
||||
debitName: string;
|
||||
debitAmount: number;
|
||||
|
Loading…
x
Reference in New Issue
Block a user