Class: OpportunityBriefing::QuoteRevisionChange

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/opportunity_briefing/quote_revision_change.rb

Overview

Serializes one added, removed, or changed product in a quote revision.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/opportunity_briefing/quote_revision_change.rb', line 14

def call
  return Result.new if previous == current

  Result.new(data: {
    sku: current&.dig(:sku) || previous&.dig(:sku),
    name: current&.dig(:name) || previous&.dig(:name),
    change: change_type,
    previous_quantity: previous&.dig(:quantity),
    current_quantity: current&.dig(:quantity),
    previous_total: previous&.dig(:total),
    current_total: current&.dig(:total)
  }.compact)
end