Class: Ncr::ProposalForm

Inherits:
Object
  • Object
show all
Includes:
SimpleFormObject
Defined in:
app/models/ncr/proposal_form.rb

Constant Summary collapse

EXPENSE_TYPES =
%w(BA61 BA80)
BUILDING_NUMBERS =
DATA['BUILDING_NUMBERS']
OFFICES =
DATA['OFFICES']

Instance Method Summary collapse

Instance Method Details

#approver_emailsObject


47
48
49
50
51
52
53
54
# File 'app/models/ncr/proposal_form.rb', line 47

def approver_emails
  emails = [self.approver_email, self.budget_approver_email]
  if self.requires_finance_approval?
    emails << self.finance_approver_email
  end

  emails
end

#budget_approver_emailObject


35
36
37
# File 'app/models/ncr/proposal_form.rb', line 35

def budget_approver_email
  ENV['NCR_BUDGET_APPROVER_EMAIL'] || '[email protected]'
end

#create_cartObject


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/models/ncr/proposal_form.rb', line 56

def create_cart
  cart = Cart.new(
    flow: 'linear',
    name: self.description
  )
  if cart.save
    cart.set_props(
      origin: self.origin,
      amount: self.amount,
      expense_type: self.expense_type,
      vendor: self.vendor,
      not_to_exceed: self.not_to_exceed,
      building_number: self.building_number,
      rwa_number: self.rwa_number,
      office: self.office
    )
    cart.set_requester(self.requester)
    self.approver_emails.each do |email|
      cart.add_approver(email)
    end
  end

  cart
end

#finance_approver_emailObject


39
40
41
# File 'app/models/ncr/proposal_form.rb', line 39

def finance_approver_email
  ENV['NCR_FINANCE_APPROVER_EMAIL'] || '[email protected]'
end

#requires_finance_approval?Boolean

Returns:

  • (Boolean)

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

def requires_finance_approval?
  self.expense_type == 'BA61'
end