abiao пре 4 година
родитељ
комит
b1c0879037
1 измењених фајлова са 12 додато и 4 уклоњено
  1. 12 4
      app/models/cash_balance.rb

+ 12 - 4
app/models/cash_balance.rb

@@ -41,10 +41,16 @@ class CashBalance < ActiveRecord::Base
       return self.count
     end
   end
-  $total=0
+  total=0
+  list=[]
   def get_happen_total
-    $total= $total+self.count
-    return $total
+    unless list.include?(3)
+      list.append(self.id)
+    end
+
+    total =  CashBalance.where(id: list).sum("count")
+
+    return total
   end
 
   def profit_state
@@ -92,7 +98,9 @@ class CashBalance < ActiveRecord::Base
       # field :updated_at
 
       field :get_happen_total do
-        visible true
+        formatted_value do
+          value.to_f / 100.0
+        end
       end
     end