Commit d2e7ecbb authored by o@immerda.ch's avatar o@immerda.ch
Browse files

support for a bill subject

parent a6e87fc5
......@@ -42,11 +42,15 @@ class BillsController < ApplicationController
def create
ttl = 6*365
amount = params[:amount].to_f
subject = params[:subject]
reference = api.get_fresh_global_transaction_key('bill', 20, ttl)
reference = reference['key']
if reference.length == 20
api.add_user_transaction('bill',
{reference: reference, amount: amount, currency: 'CHF'}, ttl)
{reference: reference,
amount: amount,
currency: 'CHF',
subject: subject}, ttl)
end
redirect_to action: :show
rescue ApiError => e
......
......@@ -3,6 +3,10 @@
<%= label_tag "CHF" %>
<%= text_field_tag('amount', "", class: 'form-control') %>
</div>
<div class="form-group">
<%= label_tag "subject" %>
<%= text_field_tag('subject', "", class: 'form-control') %>
</div>
<%= submit_tag t(:create), name: 'create', class: "btn btn-primary" %>
<% end %>
......@@ -12,8 +16,8 @@
<%= form_tag "", method: :get do %>
<div class="form-group">
<%= select_tag(:year,
options_for_select([['----',nil]]+(0..5).map{|d| DateTime.now.year - d },
@year || '----'),
options_for_select((0..5).map{|d| DateTime.now.year - d },
@year),
onchange: 'submit()') %>
</div>
<% end %>
......@@ -28,6 +32,8 @@
sum[p[:currency]] += (p[:amount] || 0)
end %>
<%= "#{date.day}.#{date.month}.#{date.year}" %>:
<%= bill[:subject] %>
<br />&nbsp;&nbsp;
<%= bill[:currency] %>
<% if bill[:amount] > 0.0 %>
<%= bill[:amount] %>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment