feat(backend): generate PDF inheritance audit reports (#825)#909
Open
DammyAji wants to merge 5 commits into
Open
feat(backend): generate PDF inheritance audit reports (#825)#909DammyAji wants to merge 5 commits into
DammyAji wants to merge 5 commits into
Conversation
- Add printpdf = 0.7 dependency for pure-Rust PDF generation - Add ping_logs migration (plan_id, pinged_at, accrued_yield_snapshot) - Add src/pdf.rs module with PlanReportData / generate() using built-in fonts - Add GET /api/plans/:id/report handler protected by JWT middleware - PDF includes owner, token, amount, status, yield, beneficiaries with allocation percentages, and full ping activity log with yield snapshots - PDF generation runs in tokio::task::spawn_blocking (never blocks Axum runtime) - Returns application/pdf with Content-Disposition: attachment Closes Fracverse#825
- Keep both printpdf and redis dependencies in Cargo.toml - Merge PDF report handler into master's api.rs (cache, KYC endpoints, paginated payouts, jwt_auth_middleware for /api/plans/:id/report) - Add pub mod pdf alongside pub mod cache in lib.rs - Restore config.rs, main.rs, inactivity_watchdog.rs, yield_calculator.rs, and cache.rs to match master (redis/PlanCache support)
…-report Resolve conflicts with upstream master (rate-limiting, metrics, security middleware): - backend/Cargo.toml: keep printpdf + redis alongside new dashmap, prometheus, once_cell - backend/src/api.rs: graft PDF handler + admin_routes + PingLogRow on top of upstream's rate-limit middleware, strict CORS, and metrics changes - backend/src/lib.rs: keep pub mod pdf alongside new pub mod metrics + pub mod middleware Closes Fracverse#825
Fix all cargo fmt --check failures: - pdf.rs: wrap long line!() macro calls to multi-line rustfmt style - api.rs: reformat spawn_blocking match block per rustfmt Closes Fracverse#825
Author
|
@ONEONUORA please kindly review now |
Contributor
|
@DammyAji |
Author
|
@ONEONUORA ok |
- api.rs: revert pdf_bytes match block to rustfmt-canonical style (method-chain .await on its own line with opening brace on same line) - pdf.rs: collapse short line!() macro calls back to single-line form; only wrap the 3 lines that actually exceed 100 chars - auth.rs: remove redundant match where both arms return the same StatusCode::UNAUTHORIZED (fixes clippy::match-like-matches-macro)
Author
|
@ONEONUORA please tell me i am done |
Contributor
|
@DammyAji |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #825
Summary
Implements the PDF inheritance audit report generation feature for issue Fracverse/InheritX#825.
Adds
GET /api/plans/:id/report— a JWT-protected endpoint that generates and streams a downloadable PDF audit report for a given inheritance plan.Changes
backend/src/pdf.rs(new)PlanReportData,BeneficiaryData,PingLogDatastructs for report inputgenerate()usingprintpdfto build an A4 PDF with Plan Details, Beneficiaries, Activity Log sections and automatic page-breakbackend/src/api.rsPingLogRowsqlx struct to query theping_logstableadmin_routesblock protected byjwt_auth_middlewareGET /api/plans/:id/reportunder admin routesget_plan_reporthandler runs PDF generation viatokio::task::spawn_blockingand returnsapplication/pdfbackend/src/lib.rspub mod pdfbackend/Cargo.tomlprintpdf = "0.7"backend/migrations/20260627000000_add_ping_logsping_logstableMerge Conflicts Resolved
All conflicts with upstream master resolved (rate-limiting, metrics, security middleware):
backend/Cargo.toml: keptprintpdf+redisalongside upstreamdashmap,prometheus,once_cellbackend/src/api.rs: merged PDF handler on top of upstream rate-limit middleware, strict CORS, and metricsbackend/src/lib.rs: retainedpub mod pdfalongsidepub mod metrics+pub mod middlewareAcceptance Criteria
GET /api/plans/:id/reportwith JWT security checktokio::task::spawn_blocking)Closes #825