Class: Belvo::TaxReturn

Inherits:
Resource show all
Defined in:
lib/belvo/resources.rb

Overview

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.

Defined Under Namespace

Classes: TaxReturnType

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Instance Method Summary collapse

Methods inherited from Resource

#clean, #delete, #detail, #list

Constructor Details

#initialize(session) ⇒ TaxReturn

Returns a new instance of TaxReturn.



445
446
447
448
# File 'lib/belvo/resources.rb', line 445

def initialize(session)
  super(session)
  @endpoint = 'api/tax-returns/'
end

Instance Method Details

#resume(_session_id, _token, _link: nil) ⇒ Object



482
483
484
# File 'lib/belvo/resources.rb', line 482

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) ⇒ Hash

Retrieve tax returns information from a specific fiscal link.

Parameters:

  • link (String)

    Link UUID

  • year_from (Integer) (defaults to: nil)
  • year_to (Integer) (defaults to: nil)
  • options (TaxReturnOptions) (defaults to: nil)

    Configurable properties

Returns:

  • (Hash)

    created tax returns details

Raises:



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/belvo/resources.rb', line 462

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