diff --git a/report_generator.rb b/report_generator.rb index fd09dda..fa06a3f 100644 --- a/report_generator.rb +++ b/report_generator.rb @@ -9,7 +9,7 @@ class ReportGenerator < Sinatra::Base post '/kif/?' do @kif_info = JSON.parse(params["data"]) - generate_pdf + generate_pdf('reports/kif-report-template.html') Pony.mail(:to => @kif_info["email"], :from => 'noreply@receipt-yourself.com', :subject => 'hi', @@ -19,8 +19,20 @@ class ReportGenerator < Sinatra::Base status 200 end - def generate_pdf - kit = PDFKit.new(erb :'reports/kif-report-template.html') + post '/kuf/?' do + @kuf_info = JSON.parse(params["data"]) + generate_pdf('reports/kuf-report-template.html') + Pony.mail(:to => @kuf_info["email"], + :from => 'noreply@receipt-yourself.com', + :subject => 'hi', + :body => "Hello there. It is #{DateTime.now}. Enjoy your KUF report.", + :attachments => {"KUF_report_#{DateTime.now}.pdf" => File.read(@file)}) + + status 200 + end + + def generate_pdf(pdf_path) + kit = PDFKit.new(erb pdf_path.to_sym) kit.stylesheets << 'views/reports/css/bootstrap-theme.min.css' kit.stylesheets << 'views/reports/css/bootstrap.min.css' kit.stylesheets << 'views/reports/css/style.css' diff --git a/views/reports/kif-report-template.html.erb b/views/reports/kif-report-template.html.erb index 28634d8..86e2d96 100644 --- a/views/reports/kif-report-template.html.erb +++ b/views/reports/kif-report-template.html.erb @@ -24,7 +24,7 @@
Report requester: <%= @kif_info["email"] %>
- Requester company: <%= @kif_info["info"][0]["financial_year"]["company"]["name"] %> + Requester company: <%= @kif_info["company"]["name"] %> diff --git a/views/reports/kuf-report-template.html.erb b/views/reports/kuf-report-template.html.erb new file mode 100644 index 0000000..9fbd084 --- /dev/null +++ b/views/reports/kuf-report-template.html.erb @@ -0,0 +1,113 @@ + + + + + + + + Report + + + + + + + + + + +
+
+
+
+ Report date: <%= Date.today %> +
+ Report requester: <%= @kuf_info["email"] %> +
+ Requester company: <%= @kuf_info["company"]["name"] %> +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + <% @kuf_info["info"].each do |kif| %> + + + + + + + + + + + <% end %> + + +
+ Number + + Payment Amount + + Remaining Amount + + Issuance Date + + Circulation Date + + Payment Deadline + + Business Partner + + Financial Year +
+ <%= kif["number"] %> + + <%= kif["payment_amount"] %> + + <%= kif["remaining_amount"] %> + + <%= kif["issuance_date"] %> + + <%= kif["circulation_date"] %> + + <%= kif["payment_deadline"] %> + + <%= kif["business_partner"]["name"] %> + + <%= kif["financial_year"]["year"] %> +
+
+
+
+
+
+
 
+
+

+ _________________________________ +

+

+ On date: <%= Date.today %> +

+
+
+
+ + \ No newline at end of file