Open geekelo opened 3 months ago
This file configures the ActiveAdmin interface for managing and generating reports on Card::Load
records, referred to as "Card Load Reports." Here's a detailed explanation:
card_load_report.rb
require 'prawn'
and require 'prawn/table'
: These are required for generating PDF files using the Prawn library, which is a popular Ruby tool for creating PDFs.Card::Load
model with ActiveAdmin under the alias CardLoadReport
, which will be used for reporting purposes rather than direct CRUD operations.CardLoadReport
resource under the "Reports" menu with the label "Card Load Reports" in the ActiveAdmin interface.Customizes the index page title to "Card Load Reports by Date Range."
panel "Filter Card Load Reports" do
transactions_by_date_form
, which presumably allows the user to filter reports by date range and status.panel "Report Downloads" do
This block defines custom controller actions and filters for handling requests.
before_action :set_date_range, only: [:index]
def set_date_range
start_date
and end_date
from the request parameters. If the dates are invalid or missing, it defaults to today's date.def index
Card::Load
records within the specified date range and filters them by status if provided.generate_csv
method and sends it as a file download.generate_pdf
method and sends it as a file download.transactions
. It includes headers like "User ID", "External Id", "Status", etc., and iterates over each transaction to populate the rows.Generates a summary PDF using Prawn. The PDF includes:
The table is styled with bold headers, centered text, and alternating row colors.
Card::Load
records.This setup is ideal for a system that requires detailed and summarized reporting on card load transactions, providing administrators with flexible tools to analyze and export data.
FILE