Skip to content

Commit

Permalink
Merge branch 'develop' into invoice-validations
Browse files Browse the repository at this point in the history
  • Loading branch information
lcreid committed Mar 7, 2017
2 parents d8a21ba + ac90712 commit 202c945
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/cf0925s.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $(document).on('turbolinks:load', function() {
// console.log('Updating the item total: ' + $('#cf0925_item_total').val());
$('#cf0925_item_total').val($(item_ids).toArray().reduce(function(a, b) {
// console.log('a, b: ', + a + ', ' + b.value);
return b.value === undefined? a: a + Number(b.value);
return $.isNumeric(b.value)? a + Number(b.value.replace(/[,$]/g, "")): a;
}, 0).toFixed(2));
// console.log('Updated the item total: ' + $('#cf0925_item_total').val());
};
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/invoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $(document).on('turbolinks:load', function() {
function update_out_of_pocket() {
allocated_spending = allocation_fields().toArray().reduce(function(a, b) {
// console.log('update_out_of_pocket b: ' + b.value);
return b.value === undefined? a: a + Number(b.value.replace(/[,$]/g, ""));
return $.isNumeric(b.value)? a + Number(b.value.replace(/[,$]/g, "")): a;
}, 0);

// console.log('allocated_spending: ' + allocated_spending);
Expand Down
11 changes: 8 additions & 3 deletions app/controllers/cf0925s_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ def create
@cf0925.allocate
# puts "#{__LINE__}: #{@cf0925.invoice_allocations.inspect}"

notice = 'Request saved.'
notice += ' Parent data updated.' if user.changed?

# I didn't need to save addresses explicitly here.
if @cf0925.save_with_user
# Get the missing fields, aka help info, for the object
@cf0925.funded_person.selected_fiscal_year = @cf0925.fiscal_year if @cf0925.fiscal_year
# TODO: why can't I just render :edit here?
redirect_to home_index_path, notice: 'Request saved.'
redirect_to home_index_path, notice: notice
else
# Get the missing fields, aka help info, for the object
@cf0925.printable?
Expand All @@ -87,10 +89,13 @@ def update

@cf0925.allocate

notice = 'Request updated.'
notice += ' Parent data updated.' if user.changed?

# I didn't need to save addresses explicitly here.
if @cf0925.save_with_user
@cf0925.funded_person.selected_fiscal_year = @cf0925.fiscal_year if @cf0925.fiscal_year
redirect_to home_index_path, notice: 'Request updated.'
redirect_to home_index_path, notice: notice
else
# Get the missing fields, aka help info, for the object
@cf0925.printable?
Expand Down
1 change: 1 addition & 0 deletions app/models/cf0925.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ def part_b_fiscal_year
# TODO: Think about this. Playing games with the value here made the
# select box hard to work with. I couldn't just use the defaults, and have
# to manually call to_s to make things work.
# FIXME: I should be able to define this as an attribute of type FiscalYear
def part_b_fiscal_year=(value)
if value.is_a?(FiscalYear)
super value.to_s
Expand Down

0 comments on commit 202c945

Please sign in to comment.