d50c1c5bba
- Added .env.example for environment variable configuration. - Created app initialization files and core settings management. - Implemented API routers for reporting and transaction endpoints. - Developed transaction management service with CRUD operations. - Integrated Azure OAuth for user authentication. - Designed dashboard view with transaction filtering and display. - Added Swagger UI documentation with custom dark theme. - Created static and template files for frontend styling and layout.
93 lines
2.6 KiB
Python
93 lines
2.6 KiB
Python
from datetime import date
|
|
from typing import Literal
|
|
|
|
from app.service.models import ReconSummary, Transaction
|
|
|
|
StatusType = Literal["Matched", "Unmatched", "Pending"]
|
|
FlagType = Literal["None", "Duplicate", "Threshold Breach", "Manual Review"]
|
|
|
|
|
|
TRANSACTIONS: list[Transaction] = [
|
|
Transaction(
|
|
transaction_id="TXN-001",
|
|
date=date(2026, 4, 10),
|
|
account="ACC-9821",
|
|
amount=12400.00,
|
|
status="Matched",
|
|
flag="None",
|
|
),
|
|
Transaction(
|
|
transaction_id="TXN-002",
|
|
date=date(2026, 4, 11),
|
|
account="ACC-4473",
|
|
amount=3750.50,
|
|
status="Unmatched",
|
|
flag="Duplicate",
|
|
),
|
|
Transaction(
|
|
transaction_id="TXN-003",
|
|
date=date(2026, 4, 11),
|
|
account="ACC-1190",
|
|
amount=88200.00,
|
|
status="Unmatched",
|
|
flag="Threshold Breach",
|
|
),
|
|
Transaction(
|
|
transaction_id="TXN-004",
|
|
date=date(2026, 4, 12),
|
|
account="ACC-6654",
|
|
amount=540.00,
|
|
status="Matched",
|
|
flag="None",
|
|
),
|
|
Transaction(
|
|
transaction_id="TXN-005",
|
|
date=date(2026, 4, 13),
|
|
account="ACC-3312",
|
|
amount=21000.00,
|
|
status="Pending",
|
|
flag="Manual Review",
|
|
),
|
|
]
|
|
|
|
|
|
def list_transactions(status: StatusType | None = None, flag: FlagType | None = None) -> list[Transaction]:
|
|
results = TRANSACTIONS
|
|
if status:
|
|
results = [item for item in results if item.status == status]
|
|
if flag:
|
|
results = [item for item in results if item.flag == flag]
|
|
return results
|
|
|
|
|
|
def get_transaction_by_id(transaction_id: str) -> Transaction | None:
|
|
for item in TRANSACTIONS:
|
|
if item.transaction_id == transaction_id:
|
|
return item
|
|
return None
|
|
|
|
|
|
def add_transaction(transaction: Transaction) -> bool:
|
|
if get_transaction_by_id(transaction.transaction_id) is not None:
|
|
return False
|
|
TRANSACTIONS.append(transaction)
|
|
return True
|
|
|
|
|
|
def delete_transaction_by_id(transaction_id: str) -> bool:
|
|
for index, item in enumerate(TRANSACTIONS):
|
|
if item.transaction_id == transaction_id:
|
|
TRANSACTIONS.pop(index)
|
|
return True
|
|
return False
|
|
|
|
|
|
def get_summary() -> ReconSummary:
|
|
return ReconSummary(
|
|
total=len(TRANSACTIONS),
|
|
matched=sum(1 for item in TRANSACTIONS if item.status == "Matched"),
|
|
unmatched=sum(1 for item in TRANSACTIONS if item.status == "Unmatched"),
|
|
pending=sum(1 for item in TRANSACTIONS if item.status == "Pending"),
|
|
flagged=sum(1 for item in TRANSACTIONS if item.flag != "None"),
|
|
)
|