class Nfe::Operations::NfeCancel

Public Class Methods

new(certificate, private_key, environment:, nfe_key:, date_time:, protocol:, reason:, use_schema: true) click to toggle source
Calls superclass method Nfe::Operations::Event::new
# File lib/nfe/operations/nfe_cancel.rb, line 6
def initialize(certificate, private_key, environment:, nfe_key:,
  date_time:, protocol:, reason:, use_schema: true)

  @event = object_event(protocol, reason)

  super(certificate, private_key, environment, nfe_key,
    sequential_number, date_time, @event, use_schema: use_schema)
end

Public Instance Methods

canceled_xml() click to toggle source
# File lib/nfe/operations/nfe_cancel.rb, line 15
def canceled_xml
  event_xml
end

Protected Instance Methods

object_event(protocol, reason) click to toggle source
# File lib/nfe/operations/nfe_cancel.rb, line 20
def object_event(protocol, reason)
  event = Services::Dispatch::DetEventoCancel.new

  event.nProt = protocol
  event.xJust = reason

  event
end
valid?() click to toggle source
Calls superclass method Nfe::Operations::Base#valid?
# File lib/nfe/operations/nfe_cancel.rb, line 29
def valid?
  if @event.nProt.to_s.length < 15
    errors.add(:base, I18n.t("nfe_cancel.invalid_protocol"))
  end

  if @event.xJust.to_s.length < 15
    errors.add(:base, I18n.t("nfe_cancel.invalid_reason"))
  end

  super
end

Private Instance Methods

sequential_number() click to toggle source
# File lib/nfe/operations/nfe_cancel.rb, line 42
def sequential_number
  1
end