Problem in Cash Register

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>

Hello,
As I am doing the JS project " Cash register" , I am facing some issues. My code gives right change but shows error when the status is open. I am looking for solutions but couldn’t find any. this is my code