Class: EducodeSales::MoneyPlan

Inherits:
ApplicationRecord show all
Defined in:
app/models/educode_sales/money_plan.rb

Instance Method Summary collapse

Instance Method Details

#return_periodObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/educode_sales/money_plan.rb', line 17

def return_period
  if self.date_at && self.business&.last_follow_up&.signed_date
    signed_date = self.business&.last_follow_up&.signed_date
    month = (self.date_at.year - signed_date.year) * 12 + self.date_at.month - signed_date.month - (self.date_at.day >= signed_date.day ? 0 : 1)
    if month <= 3
      '3个月内'
    elsif month <= 6
      '4-6个月内'
    elsif month <= 9
      '7-9个月'
    elsif month <= 12
      '10-12个月'
    elsif month <= 24
      '1-2年'
    elsif month <= 36
      '2-3年'
    else
      '3年以上'
    end
  else
    ''
  end
end