pos_configs_controller.rb 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. class PosConfigsController < ApplicationController
  2. ##--- Breadcrum_rails
  3. add_breadcrumb I18n.t("breadcrumbs." + controller_name), :pos_configs_path
  4. before_action :set_pos_config, only: [:show, :edit, :update, :destroy]
  5. # GET /pos_configs
  6. # GET /pos_configs.json
  7. def index
  8. @pos_config = PosConfig.first.blank? ? PosConfig.new : PosConfig.first
  9. end
  10. # POST /pos_configs
  11. # POST /pos_configs.json
  12. def create
  13. @pos_config = PosConfig.new(pos_config_params)
  14. respond_to do |format|
  15. if @pos_config.save
  16. format.html { redirect_to root_path, notice: 'Configuración de parametros generales guardada correctamente.' }
  17. format.json { render :show, status: :created, location: @pos_config }
  18. else
  19. format.html { render action: "index" }
  20. format.json { render json: @pos_config.errors, status: :unprocessable_entity }
  21. end
  22. end
  23. end
  24. # PATCH/PUT /pos_configs/1
  25. # PATCH/PUT /pos_configs/1.json
  26. def update
  27. respond_to do |format|
  28. @pos_config.audit_comment = "Se actualizó parametros generales"
  29. if @pos_config.update(pos_config_params)
  30. format.html { redirect_to root_path, notice: 'Configuración de parametros generales guardada correctamente.' }
  31. format.json { render :show, status: :ok, location: @pos_config }
  32. else
  33. format.html { render action: "index" }
  34. format.json { render json: @pos_config.errors, status: :unprocessable_entity }
  35. end
  36. end
  37. end
  38. private
  39. # Use callbacks to share common setup or constraints between actions.
  40. def set_pos_config
  41. @pos_config = PosConfig.first
  42. end
  43. # Never trust parameters from the scary internet, only allow the white list through.
  44. def pos_config_params
  45. params[:pos_config]
  46. params.require(:pos_config).permit(:cancel_partial_payment, :refund_sale, :days_cancel_sale, :days_cancel_purchase, :tax_percent, :time_zone, :gain_margin, :ticket_description, :reserve_sale_percent, :days_cancel_reserved, :commission_percent, :ticket_footer, :ticket_img, :ticket_img_cache, :haggle_in_sale_percent)
  47. end
  48. end