diff --git a/app/assets/javascripts/cf0925s.js b/app/assets/javascripts/cf0925s.js index fe9b065..61b5a1f 100644 --- a/app/assets/javascripts/cf0925s.js +++ b/app/assets/javascripts/cf0925s.js @@ -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()); }; diff --git a/app/assets/javascripts/invoices.js b/app/assets/javascripts/invoices.js index 8d52911..2d936d2 100644 --- a/app/assets/javascripts/invoices.js +++ b/app/assets/javascripts/invoices.js @@ -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); diff --git a/app/controllers/cf0925s_controller.rb b/app/controllers/cf0925s_controller.rb index a64b023..d9a6c57 100644 --- a/app/controllers/cf0925s_controller.rb +++ b/app/controllers/cf0925s_controller.rb @@ -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? @@ -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? diff --git a/app/models/cf0925.rb b/app/models/cf0925.rb index 459429e..b6fe677 100644 --- a/app/models/cf0925.rb +++ b/app/models/cf0925.rb @@ -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