;; svc is the :wagoe/reports component: (ig/ref :wagoe/reports)
(require '[wagoe.reports.shell.registry :as r]
'[wagoe.reports.ports :as reports])
(r/defreport invoice-report
{:id :invoice-report
:type :pdf
:page-size :a4
:filename "invoice.pdf"
;; generate passes its opts here; the result is the template's data
:data-source (fn [{:keys [invoice-id]}] (load-invoice invoice-id))
:template (fn [data]
[:html
[:head [:title "Invoice"]]
[:body
[:h1 "Invoice #" (:invoice-number data)]
[:table
[:thead [:tr [:th "Item"] [:th "Amount"]]]
[:tbody
(for [line (:lines data)]
[:tr [:td (:description line)]
[:td (str "€ " (:amount line))]])]]]])})
(def output (reports/generate svc invoice-report {:invoice-id 42}))
;=> {:bytes #bytes[...] :type :pdf :filename "invoice.pdf"}