Class: Crm::Items::PriceListsController

Inherits:
CrmController
  • Object
show all
Defined in:
app/controllers/crm/items/price_lists_controller.rb

Overview

Manages price list generation and upload.

Provides endpoints to view, create, and download price lists as PDF documents.

Instance Method Summary collapse

Instance Method Details

#createObject

Generates and uploads a price list PDF.

Returns:

  • (Object)

    redirects to upload path on success, renders new form on failure



25
26
27
28
29
30
31
32
33
# File 'app/controllers/crm/items/price_lists_controller.rb', line 25

def create
  @price_list = Pdf::Document::PriceList.new(price_list_params)

  if (@price_list_upload = @price_list.call)
    redirect_to upload_path(@price_list_upload)
  else
    render action: 'new', status: :unprocessable_content
  end
end

#newObject

Displays form to generate a new price list.

Returns:

  • (Object)

    renders the new form view



18
19
20
# File 'app/controllers/crm/items/price_lists_controller.rb', line 18

def new
  @price_list = Pdf::Document::PriceList.new(sub_title_1: 'PRICE LIST', sub_title_2: "EFFECTIVE: #{Date.current.to_fs(:crm_default)}", item_condition: 'new')
end

#showObject

Displays a price list upload by redirecting to the upload resource.

Returns:

  • (Object)

    redirects to the upload path



10
11
12
13
# File 'app/controllers/crm/items/price_lists_controller.rb', line 10

def show
  @price_list_upload = Upload.find(params[:id])
  redirect_to upload_path(@price_list_upload)
end