Class: ODDB::State::Drugs::RegisterDownload

Inherits:
Global show all
Includes:
PayPal::Checkout
Defined in:
src/state/drugs/register_download.rb

Direct Known Subclasses

RegisterInvoicedDownload

Constant Summary

VIEW =
View::Drugs::RegisterDownload
CURRENCY =
'EUR'

Constants included from PayPal::Checkout

CURRENCY

Constants inherited from Global

HOME_STATE, ZONE, ZONE_NAVIGATION

Constants inherited from Global

DIRECT_EVENT, GLOBAL_MAP, HOME_STATE, LIMITED, PRINT_STATES, READONLY_STATES, RESOLVE_STATES, REVERSE_MAP, VIEW, ZONE_NAVIGATION

Constants included from UmlautSort

FILTER_PAIRS

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from PayPal::Checkout

#ajax_autofill, #checkout, #checkout_keys, #checkout_mandatory, #create_invoice, #create_user, #currency, #user_input

Methods included from Admin::LoginMethods

#autologin, #login

Methods inherited from Global

#limit_state

Methods inherited from Global

#_search_drugs, #_search_drugs_state, #_trigger, #add_to_interaction_basket, #allowed?, #atc_chooser, #checkout, #clear_interaction_basket, #creditable?, #direct_request_path, #doctorlist, #download, #export_csv, #extend, #fachinfo, #feedbacks, #help_navigation, #home_navigation, #home_state, #hospitallist, #interaction_basket, #limit_state, #limited?, #logout, #navigation, #notify, #password_reset, #paypal_return, #powerlink, #print, #proceed_download, #proceed_poweruser, #resolve, #resolve_state, #rss, #search, #show, #snapback_event, #sort, #sponsorlink, #suggest_address, #switch, #unique_email, #user_input, #user_navigation, #ywesee_contact, #zone_navigation, #zones

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Attribute Details

- (Object) search_query (readonly)

Returns the value of attribute search_query



15
16
17
# File 'src/state/drugs/register_download.rb', line 15

def search_query
  @search_query
end

- (Object) search_type (readonly)

Returns the value of attribute search_type



15
16
17
# File 'src/state/drugs/register_download.rb', line 15

def search_type
  @search_type
end

Class Method Details

+ (Object) price(package_count)



16
17
18
19
20
21
22
23
# File 'src/state/drugs/register_download.rb', line 16

def RegisterDownload.price(package_count)
  count = package_count.to_i
  if(count <= 0)
    0
  else
    3.5 + [(count / 100.0).ceil - 1 , 0].max
  end
end

Instance Method Details

- (Object) init



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'src/state/drugs/register_download.rb', line 24

def init
  @search_query = @session.user_input(:search_query)
  @search_type = @session.user_input(:search_type) || 'st_oddb'
  package_count = @model.atc_classes.inject(0) { |inj, atc|
    inj + atc.package_count
  }
  item = AbstractInvoiceItem.new
  stype = @session.lookandfeel.lookup(@search_type)
  item.text = [@search_query, stype, 'csv'].join('.')
  item.type = :csv_export
  item.data = {
    :search_query => @search_query,
    :search_type => @search_type,
  }
  item.unit = 'Download'
  item.vat_rate = VAT_RATE
  item.total_netto = self.class.price(package_count)
  pointer = Persistence::Pointer.new(:invoice)
  @model = Persistence::CreateItem.new(pointer)
  @model.carry(:items, [item])
  @model.carry(:currency, currency)
  user = @session.user
  if(user.creditable?('org.oddb.download'))
    @model.carry(:yus_name, user.name)
    @model.carry(:email, user.name)
  end
end