Class: FraudReport

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/fraud_report.rb

Overview

== Schema Information

Table name: fraud_reports
Database name: primary

id :integer not null, primary key
billing_address_line1_check :string
billing_address_zip_check :string
billing_and_shipping_address_different :boolean
credit_card_country :string
credit_card_cvc_check :string
first_time_order :boolean default(FALSE)
is_online_order :boolean
radar_reason :string
radar_risk_level :string
shipping_state_different_to_billing_state :boolean
shipping_state_is_qc :boolean
shipping_zip_different_to_billing_zip :boolean
created_at :timestamp
updated_at :timestamp
authorization_id :integer
creator_id :integer
payment_id :integer
updater_id :integer

Indexes

index_fraud_reports_on_payment_id (payment_id)

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.distance_in_miles(distance) ⇒ String?

Parameters:

  • distance (Numeric, nil)

    distance in kilometers

Returns:

  • (String, nil)


60
61
62
63
64
# File 'app/models/fraud_report.rb', line 60

def self.distance_in_miles(distance)
  return nil if distance.nil?

  RubyUnits::Unit.new("#{distance} km").convert_to("mi").to_s
end

.pass_or_fail_boolean(res) ⇒ Boolean?

Parameters:

  • res (String)

    "pass" or "fail"

Returns:

  • (Boolean, nil)


49
50
51
52
53
54
55
56
# File 'app/models/fraud_report.rb', line 49

def self.pass_or_fail_boolean(res)
  case res
  when 'pass'
    true
  when 'fail'
    false
  end
end

Instance Method Details

#paymentPayment

Returns:



35
# File 'app/models/fraud_report.rb', line 35

belongs_to :payment

#potential_fraud?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/fraud_report.rb', line 38

def potential_fraud?
  Order::FraudDetector.potential_fraud(self)[:result] == true
end

#potential_fraud_reasonsArray<String>

Returns:

  • (Array<String>)


43
44
45
# File 'app/models/fraud_report.rb', line 43

def potential_fraud_reasons
  Order::FraudDetector.potential_fraud(self)[:reasons]
end