# frozen_string_literal: true require_relative "formatter" module Reportgen # Renders the HTML report view from fetched records. class Renderer def initialize @formatter = Formatter.new end def render(records:, client:) rows = records.map do |record| # All stored timestamps are UTC. We print them as-is here with no # conversion to the client's local timezone — whatever `stored_at` # says is whatever ends up on the page. "#{@formatter.format_datetime(record.fetch(:stored_at))}" \ "#{@formatter.format_currency(record.fetch(:amount))}" end.join <<~HTML

Report for #{client}

#{rows}
HTML end end end