Browse Source

fix when theres no sales

chemi ledon 7 years atrás
parent
commit
7779bd3efd
1 changed files with 1 additions and 1 deletions
  1. 1 1
      app/controllers/sales_controller.rb

+ 1 - 1
app/controllers/sales_controller.rb

@@ -48,7 +48,7 @@ class SalesController < ApplicationController
     pointsale = Pointsale.find(current_user.pointsale_id)
     @opened_cash_registers = pointsale.open_cash_registers.abiertas
     @sale.open_cash_register_id = session[:open_cash_register_id] || nil
-    @seller = @sale.seller_id.present? ? @sale.seller_id : pointsale.sales.activas.last.seller_id
+    @seller = @sale.seller_id.present? ? @sale.seller_id : (pointsale.sales.present? ? pointsale.sales.activas.last.seller_id : nil)
     if @pre_sales.present?
       @sale.saletype = @pre_sales[0].sale_type
       @sale.customer_id = @pre_sales[0].customer_id