Class: EME::Billing::Currency

Inherits:
Object
  • Object
show all
Defined in:
lib/eme/billing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(curr) ⇒ Currency

“VIRTUALNAME”=>“1100 EMP”, “PGCODE”=>“PAYPAL”, “CURRENCY”=>“USD”, “PAYAMT”=>10, “CASHAMT”=>1100, “CASHIDENTIFIER”=>“EMP”, “REALCASHAMT”=>1100, “BONUSCASHAMT”=>0



368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/eme/billing.rb', line 368

def initialize(curr)
  @id = curr["CURRENCYID"]
  @name = curr["VIRTUALNAME"]
  @payment_type = curr["PGCODE"]
  @position = curr["SORTNO"]
  @cost = curr["PAYAMT"]
  @cost_currency = curr["CURRENCY"]
  @purchase_amount_total = curr["CASHAMT"]
  @purchase_amount = curr["REALCASHAMT"]
  @purchase_amount_bonus = curr["BONUSCASHAMT"]
  @purchase_currency = curr["CASHIDENTIFIER"]
end

Instance Attribute Details

#costObject

Returns the value of attribute cost.



366
367
368
# File 'lib/eme/billing.rb', line 366

def cost
  @cost
end

#cost_currencyObject

Returns the value of attribute cost_currency.



366
367
368
# File 'lib/eme/billing.rb', line 366

def cost_currency
  @cost_currency
end

#idObject

Returns the value of attribute id.



366
367
368
# File 'lib/eme/billing.rb', line 366

def id
  @id
end

#nameObject

Returns the value of attribute name.



366
367
368
# File 'lib/eme/billing.rb', line 366

def name
  @name
end

#payment_typeObject

Returns the value of attribute payment_type.



366
367
368
# File 'lib/eme/billing.rb', line 366

def payment_type
  @payment_type
end

#positionObject

Returns the value of attribute position.



366
367
368
# File 'lib/eme/billing.rb', line 366

def position
  @position
end

#purchase_amountObject

Returns the value of attribute purchase_amount.



366
367
368
# File 'lib/eme/billing.rb', line 366

def purchase_amount
  @purchase_amount
end

#purchase_amount_bonusObject

Returns the value of attribute purchase_amount_bonus.



366
367
368
# File 'lib/eme/billing.rb', line 366

def purchase_amount_bonus
  @purchase_amount_bonus
end

#purchase_amount_totalObject

Returns the value of attribute purchase_amount_total.



366
367
368
# File 'lib/eme/billing.rb', line 366

def purchase_amount_total
  @purchase_amount_total
end

#purchase_currencyObject

Returns the value of attribute purchase_currency.



366
367
368
# File 'lib/eme/billing.rb', line 366

def purchase_currency
  @purchase_currency
end

Instance Method Details

#bonusObject



398
399
400
401
# File 'lib/eme/billing.rb', line 398

def bonus
  return 0 if @purchase_amount_total == 0 || @purchase_amount == 0
  (@purchase_amount_bonus.to_f * 100.0 / @purchase_amount).to_i
end

#to_sObject



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/eme/billing.rb', line 381

def to_s
  <<-CURR
  Currency #{self.object_id}
  \tid: #{@id}
  \tname: #{@name}
  \tpayment_type: #{@payment_type}
  \tposition: #{@position}
  \tcost: #{@cost}
  \tcost_currency: #{@cost_currency}
  \tpurchase_amount: #{@purchase_amount}
  \tpurchase_amount_total: #{@purchase_amount_total}
  \tpurchase_amount_bonus: #{@purchase_amount_bonus}
  \tpurchase_currency: #{@purchase_currency}
  \tbonus: #{bonus}
  CURR
end