class Belvo::TaxReturn

A Tax return is the representation of the tax return document sent every year by a person or a business to the tax authority in the country.

Public Class Methods

new(session) click to toggle source
Calls superclass method Belvo::Resource::new
# File lib/belvo/resources.rb, line 386
def initialize(session)
  super(session)
  @endpoint = 'tax-returns/'
end

Public Instance Methods

resume(_session_id, _token, _link: nil) click to toggle source
# File lib/belvo/resources.rb, line 423
def resume(_session_id, _token, _link: nil)
  raise NotImplementedError 'TaxReturn does not support resuming a session.'
end
retrieve(link:, year_from: nil, year_to: nil, options: nil) click to toggle source

Retrieve tax returns information from a specific fiscal link. @param link [String] Link UUID @param year_from [Integer] @param year_to [Integer] @param options [TaxReturnOptions] Configurable properties @return [Hash] created tax returns details @raise [RequestError] If response code is different than 2XX

# File lib/belvo/resources.rb, line 403
def retrieve(link:, year_from: nil, year_to: nil, options: nil)
  options = TaxReturnOptions.from(options)
  body = {
    link: link,
    token: options.token,
    save_data: options.save_data || true,
    attach_pdf: options.attach_pdf,
    type: options.type
  }.merge(options)
  if options.type == TaxReturnType::MONTHLY
    body[:date_from] = options.date_from
    body[:date_to] = options.date_to
  else
    body[:year_from] = year_from
    body[:year_to] = year_to
  end
  body = clean body: body
  @session.post(@endpoint, body)
end