class Wawka::Transactions::GenerateEvidence

Attributes

date[R]

Public Class Methods

new(input_date) click to toggle source
Calls superclass method
# File lib/wawka/transactions/generate_evidence.rb, line 12
def initialize(input_date)
  super({})
  @date = input_date.is_a?(Date) ? input_date : Date.parse(input_date)
end

Public Instance Methods

accumulate_services(entries) click to toggle source
# File lib/wawka/transactions/generate_evidence.rb, line 21
def accumulate_services(entries)
  Success(entries.inject({}) do |output, entry|
    task = entry.dig('task', 'name')
    output[task] ||= 0
    output[task] += entry['hours']
    output
  end)
end
be_more_enterprise(services) click to toggle source
# File lib/wawka/transactions/generate_evidence.rb, line 30
def be_more_enterprise(services)
  enterprise_services = services.inject([]) do |output, (name, hours)|
    enterprise_name = Wawka.config.dig('enterprise', name).sample
    output << { name: enterprise_name, hours: hours }
    output
  end
  Success(services: enterprise_services)
end
generate_excel(services:) click to toggle source
Calls superclass method
# File lib/wawka/transactions/generate_evidence.rb, line 39
def generate_excel(services:)
  super(
    agreement_date: Wawka.config['agreement_date'],
    name: Wawka.config['company_name'],
    services: services, 
    date: date
  )
end
prepare_date(_) click to toggle source
# File lib/wawka/transactions/generate_evidence.rb, line 17
def prepare_date(_)
  Success(date: date)
end