Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
birger
users
Commits
d2e7ecbb
Commit
d2e7ecbb
authored
Mar 15, 2021
by
o@immerda.ch
Browse files
support for a bill subject
parent
a6e87fc5
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/controllers/bills_controller.rb
View file @
d2e7ecbb
...
...
@@ -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
...
...
app/views/bills/show.html.erb
View file @
d2e7ecbb
...
...
@@ -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
/>
<%=
bill
[
:currency
]
%>
<%
if
bill
[
:amount
]
>
0.0
%>
<%=
bill
[
:amount
]
%>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment