OSDN Git Service

商品別集計が正しく集計されない不具合修正
authorymatsumoto <ymatsumoto@appirits.com>
Mon, 18 Mar 2013 10:14:43 +0000 (19:14 +0900)
committerYOSHIDA Hiroki <hyoshida@appirits.com>
Wed, 27 Mar 2013 09:35:00 +0000 (18:35 +0900)
app/controllers/admin/totals_controller.rb
app/views/admin/totals/index.html.erb
lib/totalizer.rb

index 6f09631..450b8b6 100644 (file)
@@ -6,43 +6,55 @@ class Admin::TotalsController < Admin::BaseController
 
   def index
     
-    #searchã\81®æ\97¥ä»\98ã\82\92parse
+    #searchã\81«å\95\86å\93\81é\9b\86è¨\88ç\94¨ã\81®è¦\81ç´ ã\82\92追å\8a 
     params[:search] ||= {}
     [:month, :date_from, :date_to, :sale_start_from, :sale_start_to].each do | key |
       params[:search][key] = parse_date_select(params[:search], key)
     end
-    
+   
+    #販売元id=ログインしているユーザーの販売元id 
     params[:search][:retailer_id] ||= session[:admin_user].retailer_id
-    
+   
+    #ログインユーザーのショップが無くて販売元idが違ったらエラー 
     if !session[:admin_user].master_shop? && params[:search][:retailer_id] != session[:admin_user].retailer_id
       raise ActiveRecord::RecordNotFound
     end
     
+    #OpenStructのsearch生成
     @search = OpenStruct.new(params[:search])
+
+    #:pageがnilだったら代入
     params[:page] ||= 'term'
+
+    #:pageのクラス取得
     @agent = Totalizer.get_instance(params[:page])
     
+    #取得できなかったら取得
     if not @agent
       params[:page] = 'term'
       @agent = Totalizer.get_instance(params[:page])
     end
     
+    #productのページだったらtrue
     @sale_start_enabled = (params[:page] == 'product')
     params[:type] ||= @agent.default_type
+    
+    #
     @title = @agent.title
     @list_view = @agent.columns
     @links = @agent.links
     @labels = @agent.labels
+    @total = @agent.total
     
+    #当てはまったものをレコードに入れる
     begin
       @records = @agent.get_records(params)
     rescue => e
       logger.error e.message
       e.backtrace.each{|bt|logger.error(bt)}
     end
-    
-    @total = @agent.total
-    
+
+    #
     begin
       flash[:graph] = @agent.graph
     rescue =>e
@@ -50,6 +62,7 @@ class Admin::TotalsController < Admin::BaseController
       e.backtrace.each{|bt|logger.error(bt)}
     end
     
+    #
     @selected_retailer = params[:search][:retailer_id].to_i
   end
 
index 0e13e63..9c0d174 100644 (file)
         <% end %>
       </tr>
     <% end %>
-   
+
     <% if @total %>
       <tr>
         <% @list_view.each do | column | %>
         <% end %>
       </tr>
     <% end %>
-    
+
     <tr>
       <% @labels.each do | label | %>
         <th class="result_title"><%= label and label.sub("\n", '<br />') %></th>
index 167732f..2287393 100644 (file)
@@ -345,7 +345,6 @@ class ProductTotalizer < Totalizer
   def search conditions
     records = OrderDetail.find_by_sql([<<-EOS, conditions])
       select
-        order_details.id,
         1 as position,
         product_code,
         product_name,
@@ -361,16 +360,17 @@ class ProductTotalizer < Totalizer
         join product_styles on product_styles.id = order_details.product_style_id
         join products on products.id = product_styles.product_id
       where #{WHERE_CLAUSE}
-  #{if @member == 'member'
-    " and (customers.activate in (:activate)) "
-  elsif @member == 'nomember'
-    " and (customers.activate is null) "
-  else
-    " and (customers.activate in (:activate) or customers.activate is null) "
-  end}
+        #{if @member == 'member'
+          " and (customers.activate in (:activate)) "
+        elsif @member == 'nomember'
+          " and (customers.activate is null) "
+        else
+          " and (customers.activate in (:activate) or customers.activate is null) "
+        end}
         and ((:sale_start_from is null or :sale_start_to is null)
              or products.sale_start_at between :sale_start_from and :sale_start_to)
-      group by order_details.id, product_code, product_name, unit_price, products.sale_start_at
+        and product_styles.deleted_at is null
+      group by product_code, product_name, unit_price, products.sale_start_at
       order by price desc
     EOS
     # position の振り直し & 販売開始日を Date に