Browse Source

ticket for products return

jose miguel 9 years ago
parent
commit
88a75a5694

+ 67 - 67
app/controllers/products_returns_controller.rb

@@ -6,24 +6,18 @@ class ProductsReturnsController < ApplicationController
 
   ##--- Breadcrum_rails
   add_breadcrumb I18n.t("breadcrumbs." + controller_name), :products_returns_path
-  add_breadcrumb "Nueva devolución" , :new_products_return_path, only: :new
-  add_breadcrumb "Detalle de la devolución" , :products_return_path, only: :show
-
+  add_breadcrumb "Nueva devolución", :new_products_return_path, only: :new
+  add_breadcrumb "Detalle de la devolución", :products_return_path, only: :show
 
   # GET /products_returns
   # GET /products_returns.json
   def index
-    if current_user.usertype == 'A'
-      @products_returns = ProductsReturn.all.includes(:sale, :user, :pointsale)
-    else
-      @products_returns =  Pointsale.find(current_user.pointsale_id).products_returns.includes(:sale, :user).order(" products_returns.id DESC ")
-    end
+    @products_returns = current_user.usertype == 'A' ? ProductsReturn.all.includes(:sale, :user, :pointsale) : Pointsale.find(current_user.pointsale_id).products_returns.includes(:sale, :user).order(" products_returns.id DESC ")
   end
 
   # GET /products_returns/1
   # GET /products_returns/1.json
-  def show
-  end
+  def show; end
 
   # GET /products_returns/new
   def new
@@ -31,23 +25,24 @@ class ProductsReturnsController < ApplicationController
   end
 
   # GET /products_returns/1/edit
-  def edit
-  end
+  def edit; end
 
   # POST /products_returns
   # POST /products_returns.json
+  # rubocop:disable Metrics/BlockLength
+  # rubocop:disable Metrics/BlockNesting
   def create
     respond_to do |format|
       @products_return = ProductsReturn.new
       @products_return.sale_id = params[:sale_id]
       @products_return.user_id = current_user.id
-      @products_return.return_code = "#{current_user.pointsale.prefix}-D-#{ProductsReturn.where(:pointsale_id => current_user.pointsale_id).count.next}"
+      @products_return.return_code = "#{current_user.pointsale.prefix}-D-#{ProductsReturn.where(pointsale_id: current_user.pointsale_id).count.next}"
       @products_return.pointsale_id = current_user.pointsale_id
       @products_return.new_amount = params[:new_amount]
       @products_return.returned_amount = params[:returned_amount]
       @products_return.difference_amount = params[:difference_amount]
 
-      @products_return.audit_comment = "devolucion #{@products_return.return_code} creada."
+      @products_return.audit_comment = "devolución #{@products_return.return_code} creada."
       if @products_return.save
         @products_in = JSON.parse params[:products_in]
         @products_out = JSON.parse params[:products_out]
@@ -72,17 +67,17 @@ class ProductsReturnsController < ApplicationController
             product_waste.products_return_in_id = detail.id
             product_waste.save
           else
-            stockProduct = AvailableProduct.find_by(:product_id => detail.product_id, :pointsale_id => @products_return.pointsale_id)
-            if stockProduct.present?
-              stockProduct.stock = 0 if stockProduct.stock.blank?
-              stockProduct.stock += detail.quantity
+            available_product = AvailableProduct.find_by(product_id: detail.product_id, pointsale_id: @products_return.pointsale_id)
+            if available_product.present?
+              available_product.stock = 0 if available_product.stock.blank?
+              available_product.stock += detail.quantity
             else
-              stockProduct = AvailableProduct.new
-              stockProduct.product_id = detail.product_id
-              stockProduct.pointsale_id = @products_return.pointsale_id
-              stockProduct.stock = detail.quantity
+              available_product = AvailableProduct.new
+              available_product.product_id = detail.product_id
+              available_product.pointsale_id = @products_return.pointsale_id
+              available_product.stock = detail.quantity
             end
-            stockProduct.save
+            available_product.save
           end
         end
 
@@ -93,27 +88,27 @@ class ProductsReturnsController < ApplicationController
           detail.amount = obj['amount']
           @products_return.products_return_outs << detail
 
-          stockProduct = AvailableProduct.find_by(:product_id => detail.product_id, :pointsale_id => @products_return.pointsale_id)
-          unless stockProduct.blank?
-            stockProduct.stock -= detail.quantity
-            stockProduct.save
+          available_product = AvailableProduct.find_by(product_id: detail.product_id, pointsale_id: @products_return.pointsale_id)
+          unless available_product.blank?
+            available_product.stock -= detail.quantity
+            available_product.save
           end
         end
 
         if @products_return.difference_amount > 0
-          format.js { redirect_to new_cash_registers_move_path(:products_return => @products_return.id) }
-          format.json { render :show, status: :created, location: @products_return }
+          format.js { redirect_to new_cash_registers_move_path(products_return: @products_return.id) }
         else
           format.js { flash[:success] = "Devolución creada correctamente." }
-          format.json { render :show, status: :created, location: @products_return }
         end
-
+        format.json { render :show, status: :created, location: @products_return }
       else
         format.js
         format.json { render json: @products_return.errors, status: :unprocessable_entity }
       end
     end
   end
+  # rubocop:enable Metrics/BlockLength
+  # rubocop:enable Metrics/BlockNesting
 
   # PATCH/PUT /products_returns/1
   # PATCH/PUT /products_returns/1.json
@@ -148,7 +143,7 @@ class ProductsReturnsController < ApplicationController
 
   def check_sale_detail_quantity
     detail = SalesDetail.find(params[:sale_detail_id])
-    render :json => detail.quantity
+    render json: detail.quantity
   end
 
   def add_product_to_return
@@ -158,56 +153,61 @@ class ProductsReturnsController < ApplicationController
   end
 
   def update_quantity_prod_return
-    @stock = AvailableProduct.find_by(:pointsale_id => current_user.pointsale_id, :product_id => params[:product_id])
+    @stock = AvailableProduct.find_by(pointsale_id: current_user.pointsale_id, product_id: params[:product_id])
     @product_for_return = Product.find(params[:product_id])
     @sale = Sale.find(params[:sale_id])
+    @object_totals = params[:quantity].to_i <= @stock.stock ? get_totals : nil
+    render json: @object_totals
+  end
 
-    if params[:quantity].to_i <= @stock.stock
-      @object_totals = get_totals
-    else
-      @object_totals = nil
-    end
-
-    render :json => @object_totals
+  def print_receipt
+    respond_to do |format|
+      products_return = ProductsReturn.find(params[:products_return_id])
+      pointsale = products_return.sale.get_pointsale
 
+      format.pdf do
+        render pdf: "ticket_devolucion_#{products_return.id}", template: "products_returns/receipt.pdf.erb", layout: 'receipt.html.erb', locals: { products_return: products_return, pointsale: pointsale }, show_as_html: params.key?('debug'), page_width: '80mm', page_height: '300mm'
+      end
+    end
   end
 
   private
-    # Use callbacks to share common setup or constraints between actions.
-    def set_products_return
-      @products_return = ProductsReturn.find(params[:id])
-    end
-
-    def get_totals
-      if @product_for_return.present? && @sale.present?
-        obj = Hash.new
 
-        obj['quantity'] = params[:quantity].present? ? params[:quantity] : 1
+  # Use callbacks to share common setup or constraints between actions.
+  def set_products_return
+    @products_return = ProductsReturn.find(params[:id])
+  end
 
-        obj['unit_price'] = @product_for_return.get_price_sale(current_user.pointsale_id)
+  def get_totals
+    if @product_for_return.present? && @sale.present?
+      obj = Hash.new
 
-        obj['discount'] = 0.0
-        special_price = SpecialPrice.find_by(:customer_id => @sale.customer_id, :product_id => @product_for_return.id)
-        unless special_price.blank?
-          discount_per_unit = special_price.get_unit_discount(obj['unit_price'])
-          obj['discount'] = discount_per_unit * obj['quantity'].to_i
-        end
+      obj['quantity'] = params[:quantity].present? ? params[:quantity] : 1
 
-        obj['amount'] = obj['quantity'].to_i * obj['unit_price']
+      obj['unit_price'] = @product_for_return.get_price_sale(current_user.pointsale_id)
 
-        obj['tax'] = 0.0
-        if @product_for_return.include_sale_tax == 1
-          obj['tax'] = ((PosConfig.first.tax_percent / 100) * obj['amount']).round(2)
-        end
+      obj['discount'] = 0.0
+      special_price = SpecialPrice.find_by(customer_id: @sale.customer_id, product_id: @product_for_return.id)
+      unless special_price.blank?
+        discount_per_unit = special_price.get_unit_discount(obj['unit_price'])
+        obj['discount'] = discount_per_unit * obj['quantity'].to_i
+      end
 
-        obj['total'] = ( obj['amount'] - obj['discount']) + obj['tax']
+      obj['amount'] = obj['quantity'].to_i * obj['unit_price']
 
-        return obj
+      obj['tax'] = 0.0
+      if @product_for_return.include_sale_tax == 1
+        obj['tax'] = ((PosConfig.first.tax_percent / 100) * obj['amount']).round(2)
       end
-    end
 
-    # Never trust parameters from the scary internet, only allow the white list through.
-    def products_return_params
-      params[:products_return]
+      obj['total'] = (obj['amount'] - obj['discount']) + obj['tax']
+
+      obj
     end
+  end
+
+  # Never trust parameters from the scary internet, only allow the white list through.
+  def products_return_params
+    params[:products_return]
+  end
 end

+ 3 - 3
app/models/product.rb

@@ -343,7 +343,7 @@ class Product < ActiveRecord::Base
     unless attributes_json.nil?
       attributes_to_hash.each do |attr_, value|
         description = I18n.t("dictionary." + attr_) + ": #{value}"
-        attributes = attributes.blank? ? description.to_s : attributes.to_s + ", " + description.to_s
+        attributes = attributes.blank? ? description.to_s : attributes.to_s + " " + description.to_s
       end
     end
     attributes
@@ -353,10 +353,10 @@ class Product < ActiveRecord::Base
     attributes = ""
     unless attributes_json.nil?
       attributes_to_hash.each do |_attr_, value|
-        attributes = attributes.blank? ? value.to_s : attributes.to_s + value.to_s
+        attributes = attributes.blank? ? value.to_s : attributes.to_s + " " + value.to_s
       end
     end
-    attributes
+    attributes.upcase
   end
 
   def self.most_selled_products(period, user)

+ 3 - 0
app/views/cash_registers_moves/confirm_payments.js.erb

@@ -3,8 +3,11 @@
 	$("#notice").html("<%= flash[:notice] %>");
 	var ticket_window = window.open("<%= print_receipt_path(@sale.id, format: 'pdf') %>", 'New tab', '' );
 	ticket_window.print();
+
 <% elsif @products_return.present? %>
 	window.location = "<%= products_returns_path %>";
 	$("#notice").html("<%= flash[:notice] %>");
+  var ticket_window = window.open("<%= print_return_receipt_path(@products_return.id, format: 'pdf') %>", 'New tab', '' );
+  ticket_window.print();
 <% end %>
 

+ 4 - 2
app/views/products_returns/create.js.erb

@@ -6,6 +6,8 @@ $("#error_explanation").html("")
     <% end %>
     window.scrollTo(0,0);
 <% else %>
-  	window.location = "<%= products_returns_path %>";
-	$("#notice").html("<%= flash[:notice] %>");
+  window.location = "<%= products_returns_path %>";
+  $("#notice").html("<%= flash[:notice] %>");
+  var ticket_window = window.open("<%= print_return_receipt_path(@products_return.id, format: 'pdf') %>", 'New tab', '' );
+  ticket_window.print();
 <% end %>

+ 177 - 0
app/views/products_returns/receipt.pdf.erb

@@ -0,0 +1,177 @@
+<div class='pdf-body'>
+  <header class='document-header'>
+    <h1 class='text-center'>
+      <% if pointsale.img_pointsale? %>
+        <%= wicked_pdf_image_tag_for_public(pointsale.img_pointsale_url, :style => "margin-top:10px") %>
+      <% elsif @pos_config.ticket_img? %>
+        <%= wicked_pdf_image_tag_for_public(@pos_config.ticket_img_url, :style => "margin-top:10px") %>
+      <% end %>
+    </h1>
+    <p>
+      <% if pointsale.notes.blank? %>
+        <%= simple_format(@pos_config.ticket_description, class: 'text-center') %>
+      <% else %>
+        <%= simple_format(pointsale.notes, class: 'text-center')  %>
+      <% end %>
+    </p>
+  </header>
+  <div class="resume">
+    <%= l(products_return.created_at, :format => '%d/%m/%y %I:%M %p') %> &nbsp; | &nbsp; <%= products_return.return_code %> &nbsp; | &nbsp; <%= products_return.user.first_name.upcase %>
+  </div>
+  <div style="margin-top:5px">
+    <h3 style="text-align:center">Ticket de cambio</h3>
+    Venta: <%= products_return.sale.sale_code %> <br>
+  </div>
+  <!-- productos devueltos -->
+  <div class="products">
+    <h4 style="margin-top:5px;margin-bottom:5px">PRODUCTOS CAMBIADOS</h4>
+    <table cellspacing="0">
+      <thead>
+        <tr>
+          <th style="text-align:left;font-weight:normal">Cantidad</th>
+          <th style="text-align:right;font-weight:normal">Importe</th>
+        </tr>
+      </thead>
+      <tbody style="border-top:1px solid black">
+        <% products_return.products_return_ins.each do |detail| %>
+          <tr>
+            <td colspan="2">
+              <%= truncate(detail.product.name, :length => 30, :separator => ' ', :omission => '') %> &nbsp; <%= truncate(detail.product.display_attributes_receipt, :length => 20, :separator => ' ', :omission => '') %>
+            </td>
+          </tr>
+          <tr>
+            <td>
+              <%= detail.quantity.round %>
+            </td>
+            <td style="text-align:right">
+              <%= number_to_currency(detail.amount, precision: 2) %>
+            </td>
+          </tr>
+        <% end %>
+        <tr>
+          <td colspan="2" style="text-align:right;font-size:14px">Total de productos cambiados&nbsp; <strong><%= number_to_currency(products_return.returned_amount, precision: 2) %></strong></td>
+        </tr>
+      </tbody>
+    </table>
+  </div>
+  <!-- productos nuevos -->
+  <div class="products">
+    <h4 style="margin-top:5px;margin-bottom:5px">PRODUCTOS SELECCIONADOS</h4>
+    <table cellspacing="0">
+      <thead>
+        <tr>
+          <th style="text-align:left;font-weight:normal">Cantidad</th>
+          <th style="text-align:center;font-weight:normal">Precio</th>
+          <th style="text-align:center;font-weight:normal">Desc.</th>
+          <th style="text-align:right;font-weight:normal">Importe</th>
+        </tr>
+      </thead>
+      <tbody style="border-top:1px solid black">
+        <% products_return.products_return_outs.each do |detail| %>
+          <tr>
+            <td colspan="4">
+              <%= truncate(detail.product.name, :length => 30, :separator => ' ', :omission => '') %> &nbsp; <%= truncate(detail.product.display_attributes_receipt, :length => 20, :separator => ' ', :omission => '') %>
+            </td>
+          </tr>
+          <tr>
+            <td>
+              <%= detail.quantity.round %>
+            </td>
+            <td style="text-align:center">
+              <%= number_to_currency(detail.product.get_price_sale(pointsale.id), precision: 2) %>
+            </td>
+            <td style="text-align:center">
+              <%= number_to_currency(0, precision: 2) %>
+            </td>
+            <td style="text-align:right">
+              <%= number_to_currency(detail.amount, precision: 2) %>
+            </td>
+          </tr>
+        <% end %>
+        <tr>
+          <td colspan="4" style="text-align:right;font-size:14px">Total de productos seleccionados&nbsp; <strong><%= number_to_currency(products_return.new_amount, precision: 2) %></strong></td>
+        </tr>
+      </tbody>
+    </table>
+  </div>
+
+
+  <!-- totales -->
+  <div class="totals text-right">
+    <% margin = 40 %>
+    <table>
+      <thead>
+        <tr>
+          <th></th>
+          <th></th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td width="30%" style="font-size:15px"><strong>A pagar</strong></td>
+          <td width="40%" style="font-size:15px" ><strong><%= number_to_currency(products_return.difference_amount, precision: 2) %></strong></td>
+        </tr>
+      </tbody>
+    </table>
+  </div>
+  <!-- pagos -->
+  <div style="margin-top:<%=margin%>px; border-top:1px dotted black" class="totals text-right">
+    <table cellspacing="0">
+      <thead>
+        <tr>
+          <th></th>
+          <th></th>
+          <th></th>
+        </tr>
+      </thead>
+      <tbody>
+        <% marginFooter = 20 %>
+        <% products_return.cash_registers_moves.each do |move| %>
+          <tr class="text-center" style="text-decoration:underline;">
+            <td><%= move.payment_method.method %> </td>
+            <td></td>
+            <td></td>
+          </tr>
+          <% if move.payment_method.isCash? %>
+            <% marginFooter += 80 %>
+            <tr class="text-left">
+              <td> </td>
+              <td> Recibido: </td>
+              <td> <%= number_to_currency(move.received, precision: 2) %></td>
+            </tr>
+            <tr class="text-left">
+              <td> </td>
+              <td><strong> Pagó: </strong></td>
+              <td><strong> <%= number_to_currency(move.quantity, precision: 2) %></strong></td>
+            </tr>
+            <tr class="text-left">
+              <td> </td>
+              <td> Cambio: </td>
+              <td> <%= number_to_currency(move.change, precision: 2) %></td>
+            </tr>
+          <% else %>
+            <% marginFooter += 60 %>
+              <tr class="text-left">
+                <td> </td>
+                <td><strong> Pagó: </strong></td>
+                <td><strong> <%= number_to_currency(move.quantity, precision: 2) %></strong></td>
+              </tr>
+              <tr class="text-left">
+                <td> </td>
+                <td> tarjeta nº: </td>
+                <td> <%= move.cardnumber %></td>
+              </tr>
+          <% end %>
+        <% end %>
+      </tbody>
+    </table>
+  </div>
+  <!-- footer -->
+  <div style="margin-top:<%=marginFooter%>px">
+    <% if pointsale.ticket_footer.blank? %>
+      <%= simple_format(@pos_config.ticket_footer) %>
+    <% else %>
+      <%= simple_format(pointsale.ticket_footer) %>
+    <% end %>
+  </div>
+</div>

+ 41 - 32
config/routes.rb

@@ -1,6 +1,5 @@
+# rubocop:disable Metrics/BlockLength
 Rails.application.routes.draw do
-
-
   resources :storers
   resources :warehouse_stocks
   devise_for :users, path: "/", path_names: {
@@ -12,7 +11,8 @@ Rails.application.routes.draw do
     confirmation: 'verification',
     unlock: 'unblock',
     registration: 'register',
-    sign_up: 'cmon_let_me_in' }
+    sign_up: 'cmon_let_me_in'
+  }
 
   devise_scope :user do
     get "login", to: "devise/sessions#new"
@@ -21,12 +21,12 @@ Rails.application.routes.draw do
     # get "pwdchange", to: "devise/registration#edit"
   end
 
-  #rutas para login de usuarios
+  # rutas para login de usuarios
   get "pwdchange" => "users#edit_password", :as => "pwdchange"
   patch "update_password" => "users#update_password"
   post 'update_status/:user_id' => 'users#update_status', :as => "user_update_status"
 
-  #rutas para administracion de usuarios
+  # rutas para administracion de usuarios
   get 'users' => 'users#index', :as => 'users'
   post 'users' => 'users#create'
   get 'users/new' => 'users#new', :as => 'new_user'
@@ -35,9 +35,10 @@ Rails.application.routes.draw do
   patch 'users/:id' => 'users#update'
   put 'users/:id' => 'users#update'
 
-  resources :product_wastes, :except => [:show, :edit] do
+  resources :product_wastes, except: [:show, :edit] do
     post 'create' => 'product_wastes#create', defaults: { format: 'js' }
   end
+
   resources :suppliers do
     post 'update_status' => 'suppliers#update_status', :as => "update_status"
   end
@@ -58,32 +59,37 @@ Rails.application.routes.draw do
   get '/debtors' => 'customers#debtors'
   get '/customer_sales' => 'customers#customer_sales'
 
-  resources :cash_registers, :except => [:show] do
+  resources :cash_registers, except: [:show] do
     post 'update_status' => 'cash_registers#update_status', :as => "update_status"
     get "get_cash_fund/" => "cash_registers#get_cash_fund", :as => "get_cash_fund", :format => :json
   end
-  resources :expenses, :except => [:show]
-  resources :expensesconcepts, :except => [:show]
-  resources :pointsales, :except => [:show] do
+
+  resources :expenses, except: [:show]
+
+  resources :expensesconcepts, except: [:show]
+
+  resources :pointsales, except: [:show] do
     post 'update_status' => 'pointsales#update_status', :as => "update_status"
     post 'assign_or_delete_products' => 'pointsales#assign_or_delete_products', :format => :js
     post 'delete_products_from_pointsale' => 'pointsales#delete_products_from_pointsale', :format => :js
     post 'assign_products_to_pointsale' => 'pointsales#assign_products_to_pointsale', :format => :js
-
   end
   post 'transfer_stock' => 'pointsales#transfer_stock', :as => "transfer_stock"
-  resources :categories, :except => [:show] do
+
+  resources :categories, except: [:show] do
     post 'update_status' => 'categories#update_status', :as => "update_status"
   end
-  resources :special_prices, :except => [:show, :edit] do
+
+  resources :special_prices, except: [:show, :edit] do
     post 'create' => 'special_products#create', defaults: { format: 'js' }
   end
   get 'add_special_price_by_barcode/:barcode/:customer_id' => 'special_prices#add_special_price_by_barcode', defaults: { format: 'js' }
 
   resources :credit_payments
+
   resources :products do
     post 'edit_from_purchase' => 'products#edit_from_purchase', defaults: { format: 'js' }
-    patch 'update_from_purchase' => 'products#update_from_purchase', :constraints => -> (req) { req.xhr? }
+    patch 'update_from_purchase' => 'products#update_from_purchase', :constraints => ->(req) { req.xhr? }
     post 'update_status' => 'products#update_status', :as => "update_status"
     get 'prices' => 'products#list_prices'
     get 'variantsprices/:pointsale_id' => 'products#list_prices_variants', :format => :json
@@ -93,10 +99,11 @@ Rails.application.routes.draw do
   get 'validate_unique_barcode/:barcode' => 'products#validate_unique_barcode', defaults: { format: 'js' }
   get 'product_track' => 'products#product_track', :as => "product_track"
 
-  resources :available_products, :except => [:edit, :update] do
+  resources :available_products, except: [:edit, :update] do
     get 'edit_price' => 'available_products#edit_price'
     patch 'update_price' => 'available_products#update_price'
   end
+
   resources :cash_outs
   get 'get_open_cash_registers' => 'cash_outs#get_open_cash_registers', defaults: { format: 'js' }
   post 'select_open_cash_to_close/:open_cash_register_id' => 'cash_outs#select_open_cash_to_close', defaults: { format: 'js' }
@@ -104,15 +111,18 @@ Rails.application.routes.draw do
   get 'opened_cash_registers' => 'cash_outs#opened_cash_registers'
   get 'print_cash_out_receipt/:cash_out_id' => 'cash_outs#print_receipt', :as => 'print_cash_out_receipt'
 
-  resources :sellers, :except => [:show] do
+  resources :sellers, except: [:show] do
     post 'update_status' => 'sellers#update_status', :as => "update_status"
   end
+
   resources :pos_configs
+
   resources :credits
+
   resources :purchases
   get 'find_purchases_by_date/:begin_date/:end_date' => 'purchases#find_purchases_by_date', defaults: { format: 'js' }
 
-  resources :pre_purchases, :except => [:new, :show] do
+  resources :pre_purchases, except: [:new, :show] do
     post 'create' => 'pre_purchases#create', defaults: { format: 'js' }
     put 'edit' => 'pre_purchases#update', defaults: { format: 'js' }
   end
@@ -138,7 +148,7 @@ Rails.application.routes.draw do
   get 'cancel_reserved_sale/:sale_id' => 'sales#cancel_reserved_sale', :as => 'cancel_reserved_sale'
   get 'find_sales_by_dates_or_code' => 'sales#find_sales_by_dates_or_code', defaults: { format: 'js' }
 
-  resources :pre_sales, :except => [:new, :show] do
+  resources :pre_sales, except: [:new, :show] do
     post 'create' => 'pre_sales#create', defaults: { format: 'js' }
     put 'edit' => 'pre_sales#update', defaults: { format: 'js' }
   end
@@ -147,13 +157,12 @@ Rails.application.routes.draw do
   resources :open_cash_registers do
     post 'create' => 'open_cash_registers#create', defaults: { format: 'js' }
   end
+
   resources :cash_registers_moves do
     post 'create' => 'cash_registers_moves#create', defaults: { format: 'js' }
   end
   get 'add_quick_payment/:type' => 'cash_registers_moves#add_quick_payment', defaults: { format: 'js' }, :as => "add_quick_payment"
   get 'create_quick_debt_payment/:customer_id' => 'cash_registers_moves#create_quick_debt_payment', defaults: { format: 'js' }
-
-
   post 'confirm_payments' => 'cash_registers_moves#confirm_payments', :as => "cash_move_confirm_payments"
   post 'confirm_reserve/:sale_id' => 'cash_registers_moves#confirm_reserve', :as => "cash_move_confirm_reserve"
   post 'add_payments_to_reserve/:sale_id' => 'cash_registers_moves#add_payments_to_reserve', :as => "cash_move_add_payments_to_reserve"
@@ -165,7 +174,7 @@ Rails.application.routes.draw do
   end
   get 'print_transfer_receipt/:transfer_id' => 'transfers#print_receipt', :as => 'print_transfer_receipt'
 
-  resources :pre_transfers, :except => [:new, :show] do
+  resources :pre_transfers, except: [:new, :show] do
     post 'create' => 'pre_transfers#create', defaults: { format: 'js' }
     put 'edit' => 'pre_transfers#update', defaults: { format: 'js' }
   end
@@ -180,7 +189,7 @@ Rails.application.routes.draw do
   get 'check_sale_detail_quantity' => 'products_returns#check_sale_detail_quantity'
   post 'add_product_to_return' => 'products_returns#add_product_to_return', defaults: { format: 'js' }, :as => "add_product_to_return"
   get 'update_quantity_prod_return' => 'products_returns#update_quantity_prod_return', :format => :json
-
+  get 'print_return_receipt/:products_return_id' => 'products_returns#print_receipt', :as => 'print_return_receipt'
 
   root 'dashboard#index'
   get 'get_chart_data_for_dashboard' => 'dashboard#get_chart_data_for_dashboard'
@@ -193,10 +202,9 @@ Rails.application.routes.draw do
   get 'purchases_data/products_list'
 
   # rutas pre( lo que sea, sale, purchase, etc.)
-  get 'delete_pre_purchases' => 'application#delete_pre_purchases', :constraints => -> (req) { req.xhr? }
-  get 'delete_pre_sales' => 'application#delete_pre_sales', :constraints => -> (req) { req.xhr? }
-  get 'delete_pre_transfers' => 'application#delete_pre_transfers', :constraints => -> (req) { req.xhr? }
-
+  get 'delete_pre_purchases' => 'application#delete_pre_purchases', :constraints => ->(req) { req.xhr? }
+  get 'delete_pre_sales' => 'application#delete_pre_sales', :constraints => ->(req) { req.xhr? }
+  get 'delete_pre_transfers' => 'application#delete_pre_transfers', :constraints => ->(req) { req.xhr? }
 
   # rutas para el STOCK
   get 'stock_by_pointsale' => 'available_products#stock_by_pointsale', :as => 'stock_by_pointsale'
@@ -209,20 +217,21 @@ Rails.application.routes.draw do
 
   # find de productos para el typeahead
   get 'find_products/:query' => 'application#find', :format => :json
-  #para special_prices
+  # para special_prices
   get 'find_products_sp/:query' => 'application#find_sp', :format => :json
   #
   get 'find_products_from_stock/:query' => 'application#find_from_stock', :format => :json
   get 'find_from_stock_by_pointsale/:pointsale_id/:query' => 'application#find_from_stock_by_pointsale', :format => :json
 
   get "getcategories/:category_id" => "application#get_subcategories", :as => "get_subcategories", :format => :json
-  get 'get_max_product_id'  => 'application#get_max_product_id', :format => :json
-  get 'get_max_purchaseid_by_pointsale/:pointsale_id'  => 'application#get_max_purchaseid_by_pointsale', :format => :json
-  get 'get_max_purchaseid_by_warehouse/:warehouse_id'  => 'application#get_max_purchaseid_by_warehouse', :format => :json
-  get 'get_next_sale_code/:open_cash_register_id'  => 'application#get_next_sale_code', :format => :json, :as => "get_sale_code"
-  get 'get_next_expense_code/:open_cash_register_id'  => 'application#get_next_expense_code', :format => :json, :as => "get_expense_code"
+  get 'get_max_product_id' => 'application#get_max_product_id', :format => :json
+  get 'get_max_purchaseid_by_pointsale/:pointsale_id' => 'application#get_max_purchaseid_by_pointsale', :format => :json
+  get 'get_max_purchaseid_by_warehouse/:warehouse_id' => 'application#get_max_purchaseid_by_warehouse', :format => :json
+  get 'get_next_sale_code/:open_cash_register_id' => 'application#get_next_sale_code', :format => :json, :as => "get_sale_code"
+  get 'get_next_expense_code/:open_cash_register_id' => 'application#get_next_expense_code', :format => :json, :as => "get_expense_code"
   get 'get_special_price_by_customer/:customer_id' => 'special_prices#get_special_price_by_customer', defaults: { format: 'js' }
 
   get "products_by_category_pointsale/:pointsale_id/:category_id" => "application#products_by_category_pointsale", :as => "products_by_category_pointsale", :format => :json
   get "verify_transfer/:transfer_id" => "transfers#verify_transfer", :as => "verify_transfer"
 end
+# rubocop:enable Metrics/BlockLength