Class: ODDB::State::Drugs::RegisterInvoicedDownload

Inherits:
RegisterDownload show all
Defined in:
src/state/drugs/register_download.rb

Constant Summary

VIEW =
View::Drugs::RegisterInvoicedDownload
CURRENCY =
'CHF'

Constants inherited from RegisterDownload

CURRENCY, VIEW

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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from RegisterDownload

#init

Methods included from PayPal::Checkout

#ajax_autofill, #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, #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

Class Method Details

+ (Object) price(package_count)



54
55
56
57
58
59
60
61
# File 'src/state/drugs/register_download.rb', line 54

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

Instance Method Details

- (Object) checkout



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'src/state/drugs/register_download.rb', line 63

def checkout
  if(creditable?('org.oddb.download'))
    if(@paid.nil?)
      app = @session.app
      item = @model.items.first
      slate_ptr = Persistence::Pointer.new([:slate, :download])
      slate = app.create(slate_ptr)
      item_ptr = slate_ptr + [:item]
      values = item.values
      values.store(:yus_name, @session.user.name)
      values.store(:time, Time.now)
      @paid = app.update(item_ptr.creator, values, unique_email)
    end
    State::User::Download.new(@session, @paid)
  end
end