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
open-source
aoz-003
Commits
1229484f
Commit
1229484f
authored
Sep 15, 2017
by
Kaspar Vollenweider
👻
Committed by
Kaspar
Sep 21, 2017
Browse files
directly create billing expense from volunteer view
parent
a4000dab
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/models/billing_expense.rb
View file @
1229484f
class
BillingExpense
<
ApplicationRecord
include
FullBankDetails
before_validation
:compute_amount
before_validation
:auto_set_amount
belongs_to
:volunteer
belongs_to
:user
,
->
{
with_deleted
}
has_many
:hours
...
...
@@ -25,6 +26,10 @@ class BillingExpense < ApplicationRecord
super
(
compute_amount
)
end
def
auto_set_amount
self
.
amount
=
nil
end
def
compute_amount
hour_count
=
id
?
hours_sum
:
volunteer
.
billable_hours_sum
if
hour_count
>
50
...
...
app/views/billing_expenses/index.html.slim
View file @
1229484f
...
...
@@ -30,7 +30,9 @@ h1= t_title(:index, BillingExpense)
td
=
link_to
t_action
(
:destroy
),
volunteer_billing_expense_path
(
@volunteer
,
record
),
confirm_deleting
(
record
)
.row
.col-xs-12
=
form_navigation_btn
:new
=
simple_form_for
[
@volunteer
,
BillingExpense
.
new
]
do
|
f
|
=
f
.
hidden_field
:volunteer_id
,
value:
@volunteer
.
id
=
f
.
button
:submits
.row
.col-xs-12
=
button_link
t
(
'back'
),
@volunteer
app/views/volunteers/show.html.slim
View file @
1229484f
...
...
@@ -10,8 +10,12 @@ nav.navbar.section-navigation
-
if
@volunteer
.
seeking_clients?
li
=
button_link
t_title
(
:new
,
Assignment
),
new_assignment_path
(
volunteer_id:
@volunteer
)
-
if
@volunteer
.
assignments
.
any?
li
=
button_link
t_title
(
:new
,
BillingExpense
),
new_volunteer_billing_expense_path
(
@volunteer
)
li
=
button_link
t_title
(
:index
,
BillingExpense
),
volunteer_billing_expenses_path
(
@volunteer
)
li
=
simple_form_for
[
@volunteer
,
BillingExpense
.
new
]
do
|
f
|
=
f
.
hidden_field
:volunteer_id
,
value:
@volunteer
.
id
=
f
.
button
:submits
-
if
@volunteer
.
billing_expenses
.
any?
li
=
button_link
t_title
(
:index
,
BillingExpense
),
volunteer_billing_expenses_path
(
@volunteer
)
-
if
@volunteer
.
assignments?
li
=
button_link
t
(
'.new_certificate'
),
new_volunteer_certificate_path
(
@volunteer
)
-
if
@volunteer
.
certificates
.
size
==
1
...
...
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