Class: Belvo::TaxRetentions

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

Overview

A tax retention is the amount of money that the payer must deduct from the total amount of a purchase invoice, according to the regulations of the fiscal institution.

Defined Under Namespace

Classes: TaxRetentionsType

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Instance Method Summary collapse

Methods inherited from Resource

#clean, #delete, #detail, #list

Constructor Details

#initialize(session) ⇒ TaxRetentions

Returns a new instance of TaxRetentions.



529
530
531
532
# File 'lib/belvo/resources.rb', line 529

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

Instance Method Details

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



561
562
563
564
# File 'lib/belvo/resources.rb', line 561

def resume(_session_id, _token, _link: nil)
  raise NotImplementedError \
    'TaxRetentions does not support resuming a session'
end

#retrieve(link:, type:, options: nil) ⇒ Object

Retrieve tax retentions from a specific fiscal link. for (UUID). the invoice (from the perspective of the Link owner). ‘OUTFLOW` relates to a tax retention for a sent invoice. `INFLOW` relates to a tax retention for a received invoice. (inflow or outflow)

Parameters:

  • link (String)

    The ‘link.id` that you want to get information

  • type (TaxRetentionsType)

    The type of tax retention in relation to

  • options (TaxRetentionsOptions) (defaults to: nil)

    Configurable properties



547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/belvo/resources.rb', line 547

def retrieve(link:, type:, options: nil)
  options = TaxRetentionsOptions.from(options)
  body = {
    link: link,
    date_from: options.date_from,
    date_to: options.date_to,
    save_data: options.save_data,
    attach_xml: options.attach_xml,
    type: type
  }.merge(options)
  body = clean body: body
  @session.post(@endpoint, body)
end