Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:17:01+00:00 2026-06-03T10:17:01+00:00

I have a Rails view to display a grid by PERIOD and GENERAL LEDGER,

  • 0

I have a Rails view to display a grid by PERIOD and GENERAL LEDGER, and I want to display a cumulative total. In the case below, however, my @cumulative_total in the “TOTAL” column is rounding up to the nearest dollar, so no cents are shown, even though they are displayed correctly in the general_ledger columns. Any ideas what I’m doing wrong?

<% @cumulative_total = 0 %>
<div id="gl_crosstab">
  <table>
    <tr>
      <th>Period</th>
      <% @general_ledgers.each do |g| %>
        <th><%= g.general_ledger_number %></th>
      <% end %>
      <th>Total</th>
      <th>% Expended</th>
    </tr>
    <% @expected_billings.group_by(&:period_id).each do |eb| %>
      <tr>
        <td><%= eb[1].first.period.pe_number %></td>
        <% eb[1].each do|p| %>
          <td><%= number_to_currency(p.expected_amount) %></td>
        <% end %>
        <td>
          <% @cumulative_total = @cumulative_total + eb[1].inject(0){|sum,billing| sum+billing.expected_amount.to_i} %>
          <%=  number_to_currency( @cumulative_total ) %> </td>
        <td><%= number_to_currency((@cumulative_total/@sla.project_total)*100) %> % </td>
      </tr>
    <% end %>
    <tr>
      <td><b>Total Budget</td>
      <% @total_expected_billings.each do |teb| %>
        <td><b><%= number_to_currency(teb[1].inject(0){|sum,billing| sum+billing.expected_amount.to_i}) %></td>
      <% end %>
      <td><b><%= number_to_currency(@expected_billings.inject(0){|sum,billing| sum+billing.expected_amount.to_i}) %> </td>
      <td><b><%= number_to_currency((@expected_billings.inject(0){|sum,billing| sum+billing.expected_amount.to_i}/@sla.project_total)*100) %> % </b></td>
    </tr>
  </table>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:17:03+00:00Added an answer on June 3, 2026 at 10:17 am

    I think that is because you are converting the billing amount to ‘integers’ while displaying:

    @expected_billings.inject(0){|sum,billing| sum+billing.expected_amount.to_i
    

    If you change

    billing.expected_amount.to_i  
    

    to

    billing.expected_amount.to_f  
    

    it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my rails view(index.html.erb), i have following structure <div> <%= render :partial => create
I have created model, controller and view with rails scaffold generator: rails g scaffold
I have an XML view in a rails app, and need to insert in
In my rails project I have a presenter method that has a helper view
I am beginner in rails. I have view that i try to print inside
this time it's about Ruby On Rails. I have a form in the view
I'm making a simple search form in rails. In my search view I have
In my rails application I have a set of attachments that display, with a
please help with the following:(using rails 3 and jquery) In my view i have:
I want to display a selection list of MyModel subclasses in a view. It's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.