Class: Marketing::CampaignInfluence::Row

Inherits:
Data
  • Object
show all
Defined in:
app/queries/marketing/campaign_influence.rb

Overview

One campaign's influence over the period.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#campaign_idObject (readonly)

Returns the value of attribute campaign_id

Returns:

  • (Object)

    the current value of campaign_id



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def campaign_id
  @campaign_id
end

#campaign_nameObject (readonly)

Returns the value of attribute campaign_name

Returns:

  • (Object)

    the current value of campaign_name



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def campaign_name
  @campaign_name
end

#influenced_invoicesObject (readonly)

Returns the value of attribute influenced_invoices

Returns:

  • (Object)

    the current value of influenced_invoices



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def influenced_invoices
  @influenced_invoices
end

#influenced_revenueObject (readonly)

Returns the value of attribute influenced_revenue

Returns:

  • (Object)

    the current value of influenced_revenue



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def influenced_revenue
  @influenced_revenue
end

#net_new_invoicesObject (readonly)

Returns the value of attribute net_new_invoices

Returns:

  • (Object)

    the current value of net_new_invoices



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def net_new_invoices
  @net_new_invoices
end

#period_revenueObject (readonly)

Returns the value of attribute period_revenue

Returns:

  • (Object)

    the current value of period_revenue



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def period_revenue
  @period_revenue
end

#source_idObject (readonly)

Returns the value of attribute source_id

Returns:

  • (Object)

    the current value of source_id



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def source_id
  @source_id
end

#sourced_invoicesObject (readonly)

Returns the value of attribute sourced_invoices

Returns:

  • (Object)

    the current value of sourced_invoices



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def sourced_invoices
  @sourced_invoices
end

#sourced_revenueObject (readonly)

Returns the value of attribute sourced_revenue

Returns:

  • (Object)

    the current value of sourced_revenue



61
62
63
# File 'app/queries/marketing/campaign_influence.rb', line 61

def sourced_revenue
  @sourced_revenue
end

Instance Method Details

#always_on?Boolean

Reach this broad stops discriminating between campaigns.

Returns:

  • (Boolean)


93
# File 'app/queries/marketing/campaign_influence.rb', line 93

def always_on? = coverage_of_period >= ALWAYS_ON_COVERAGE

#coverage_of_periodFloat

Share of ALL revenue in the period this campaign touched, 0.0..1.0.

The base rate is not decoration — it is what makes the influence figure
readable. An always-on programme that touches half the company's invoices
tops any influence ranking by construction, so "$283k influenced" means
nothing until you know it is 38% of everything billed. Reporting the
revenue without this invites exactly the decision the number was built to
prevent.

Returns:

  • (Float)


84
85
86
87
88
# File 'app/queries/marketing/campaign_influence.rb', line 84

def coverage_of_period
  return 0.0 if period_revenue.to_f.zero?

  (influenced_revenue.to_f / period_revenue).round(4)
end

#influence_only_invoicesInteger

Returns:

  • (Integer)


72
# File 'app/queries/marketing/campaign_influence.rb', line 72

def influence_only_invoices = influenced_invoices - sourced_invoices

#influence_only_revenueBigDecimal

Revenue the campaign touched but did NOT acquire. The honest "we helped"
number, once the deals it already gets first-touch credit for are out.

Returns:

  • (BigDecimal)


69
# File 'app/queries/marketing/campaign_influence.rb', line 69

def influence_only_revenue = influenced_revenue - sourced_revenue