Skip to content

Add comprehensive export system supporting CSV, XLSX, JSON, PDF#7

Open
cmbaldwin wants to merge 2 commits intomasterfrom
claude/plan-export-formats-skRou
Open

Add comprehensive export system supporting CSV, XLSX, JSON, PDF#7
cmbaldwin wants to merge 2 commits intomasterfrom
claude/plan-export-formats-skRou

Conversation

@cmbaldwin
Copy link
Copy Markdown
Owner

Summary

Implements a unified, extensible export system for the Oroshi application supporting CSV, XLSX, JSON, and PDF formats across all major data views (Orders, Revenue, Production, Inventory, Supply, and Shipping). All exports are processed asynchronously via Solid Queue using the existing Message + ActiveStorage pattern.

Key Changes

Core Export Infrastructure

  • lib/exports/base_export.rb: Abstract base class providing format dispatch, data loading, filtering, and column definitions
  • Format mixins: csv_export.rb, xlsx_export.rb, json_export.rb, pdf_export.rb for format-specific generation
  • Data-specific exporters: orders_export.rb, revenue_export.rb, production_export.rb, inventory_export.rb, supply_export.rb, shipping_export.rb with Japanese column headers and domain-specific logic

Job & Controller

  • app/jobs/oroshi/export_job.rb: Unified async job replacing per-document-type pattern; generates content and attaches to Message.stored_file
  • app/controllers/oroshi/exports_controller.rb: Handles export requests with validation for export types and formats; creates Message records and enqueues jobs

UI & Localization

  • app/views/oroshi/exports/_export_button.html.erb: Reusable dropdown button partial for all dashboard views
  • app/views/oroshi/exports/_date_range_export.html.erb: Modal form for date range selection
  • config/locales/exports.ja.yml & exports.en.yml: Japanese and English translations
  • app/helpers/oroshi/exports_helper.rb: Format icon mapping helper
  • Modified dashboard views: Added export buttons to orders, production, and supply dashboards

Authorization & Routing

  • app/policies/oroshi/export_policy.rb: Policy allowing Admin, VIP, and Employee roles to export
  • config/routes.rb: Added resources :exports, only: [:create] route

Testing

  • Comprehensive test suite covering all export classes, job execution, controller validation, and format generation
  • Tests verify data filtering, column definitions, and file attachment

Implementation Details

  • Format support: CSV (with UTF-8 BOM for Excel compatibility), XLSX (via caxlsx gem), JSON (with metadata), PDF (via existing Printable class)
  • Filtering: Supports buyer IDs, shipping methods, order categories, buyer categories, and date ranges
  • Async processing: Jobs track status via Message.state (nil → true/false) and attach files to Message.stored_file
  • Revenue export: Includes summary rows with subtotals and net profit calculations
  • Production export: Queries ±1 day buffer matching production dashboard behavior
  • Shipping export: PDF delegates to existing OroshiOrderDocument for B4 landscape layout; CSV/XLSX/JSON provide flattened data

Dependencies

Added gem "caxlsx" for XLSX generation (community-maintained successor to axlsx).

https://claude.ai/code/session_01VBKF79FuRwrf32F3WFCTJ6

Implement a unified export framework supporting all major data views:
- Order list, revenue/profit, production/factory floor, inventory,
  supply intake, and shipping chart exports
- All 4 formats: CSV (BOM for Excel JP), XLSX (caxlsx), PDF (Prawn),
  and JSON with metadata
- Async generation via Solid Queue (ExportJob) with Message tracking
- Reusable export button partial with format dropdown + date range modal
- Pundit authorization (ExportPolicy) matching order read access
- Japanese-first i18n translations (exports.ja.yml + exports.en.yml)
- Export buttons wired into all dashboard tabs (orders, revenue,
  shipping, production, supply usage, supply dates)
- Comprehensive test suite: 9 test files covering base export,
  all data exporters, job execution, and controller authorization

https://claude.ai/code/session_01VBKF79FuRwrf32F3WFCTJ6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants