Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions lib/nfcom/builder/danfe_com.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ def setup_fonts(pdf)
pdf.font 'Helvetica'
end

# rubocop:disable Metrics/AbcSize
def gerar_conteudo(pdf)
ide = xml_doc.at_xpath('//xmlns:ide', 'xmlns' => ns)
ide = xml_doc.at_xpath('//xmlns:ide', 'xmlns' => ns)
emit = xml_doc.at_xpath('//xmlns:emit', 'xmlns' => ns)
dest = xml_doc.at_xpath('//xmlns:dest', 'xmlns' => ns)
total = xml_doc.at_xpath('//xmlns:total', 'xmlns' => ns)
Expand All @@ -75,12 +74,10 @@ def gerar_conteudo(pdf)
gerar_info_adicional(pdf, inf_adic) if inf_adic
gerar_rodape(pdf, ide, prot)
end
# rubocop:enable Metrics/AbcSize

# ----------------------------
# HEADER / LOGO
# ----------------------------
# rubocop:disable Metrics/AbcSize
def gerar_cabecalho(pdf, y_pos)
if logo_path && File.exist?(logo_path)
begin
Expand All @@ -103,7 +100,6 @@ def gerar_cabecalho(pdf, y_pos)

y_pos - 22.mm
end
# rubocop:enable Metrics/AbcSize

def renderizar_logo_svg(pdf, y_pos)
raise 'prawn-svg não instalado' unless defined?(Prawn::Svg)
Expand All @@ -114,7 +110,6 @@ def renderizar_logo_svg(pdf, y_pos)
# ----------------------------
# EMITENTE / DESTINATARIO
# ----------------------------
# rubocop:disable Metrics/AbcSize
def gerar_info_emitente_documento(pdf, emit, ide, y_pos)
pdf.stroke_rectangle [0, y_pos], 200.mm, 30.mm
emit_info = extrair_emitente(emit)
Expand Down Expand Up @@ -143,9 +138,7 @@ def gerar_info_emitente_documento(pdf, emit, ide, y_pos)

y_pos - 33.mm
end
# rubocop:enable Metrics/AbcSize

# rubocop:disable Metrics/AbcSize
def gerar_destinatario(pdf, dest, y_pos)
pdf.stroke_rectangle [0, y_pos], 200.mm, 28.mm
dest_info = extrair_destinatario(dest)
Expand All @@ -172,7 +165,6 @@ def gerar_destinatario(pdf, dest, y_pos)

y_pos - 32.mm
end
# rubocop:enable Metrics/AbcSize

# ----------------------------
# QR CODE
Expand Down Expand Up @@ -238,7 +230,7 @@ def renderizar_texto_consulta(pdf, y_pos)
# ----------------------------
# EXTRACTION METHODS
# ----------------------------
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def extrair_emitente(emit)
return {} unless emit

Expand Down Expand Up @@ -274,7 +266,7 @@ def extrair_destinatario(dest)
cep: dest.at_xpath('xmlns:enderDest/xmlns:CEP', 'xmlns' => ns)&.text
}
end
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

# ----------------------------
# HELPER METHODS
Expand Down Expand Up @@ -355,7 +347,7 @@ def formatar_data_hora_xml(datetime)
# ----------------------------
# ASSINANTE
# ----------------------------
def gerar_assinante(pdf, assinante, y_pos) # rubocop:disable Metrics/AbcSize
def gerar_assinante(pdf, assinante, y_pos)
pdf.stroke_rectangle [0, y_pos], 200.mm, 18.mm
pdf.text_box 'DADOS DO ASSINANTE', at: [2.mm, y_pos - 2.mm], size: 10, style: :bold

Expand Down Expand Up @@ -386,7 +378,6 @@ def tipo_servico_texto(codigo)
# ----------------------------
# FATURAMENTO
# ----------------------------
# rubocop:disable Metrics/AbcSize
def gerar_faturamento(pdf, gfat, y_pos)
pdf.stroke_rectangle [0, y_pos], 200.mm, 22.mm
pdf.text_box 'INFORMAÇÕES DE FATURAMENTO', at: [2.mm, y_pos - 2.mm], size: 10, style: :bold
Expand All @@ -413,7 +404,6 @@ def gerar_faturamento(pdf, gfat, y_pos)

y_pos - 25.mm
end
# rubocop:enable Metrics/AbcSize

def formatar_competencia(comp)
return '' unless comp
Expand All @@ -430,15 +420,14 @@ def formatar_data_simples(data)
end

def formatar_codigo_barras(codigo)
Fatura::CodigoDeBarras.new(codigo).linha_digitavel
Nfcom::Models::Fatura::CodigoDeBarras.new(codigo).linha_digitavel
rescue StandardError
''
end

# ----------------------------
# ITENS
# ----------------------------
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def gerar_itens(pdf, itens, y_pos)
y_pos -= 5.mm
pdf.move_cursor_to(y_pos)
Expand Down Expand Up @@ -472,7 +461,6 @@ def gerar_itens(pdf, itens, y_pos)

pdf.cursor
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength

def unidade_texto(codigo)
{ '1' => 'Min', '2' => 'MB', '3' => 'GB', '4' => 'UN' }[codigo] || codigo
Expand All @@ -493,7 +481,6 @@ def formatar_moeda(valor)
# ----------------------------
# TOTAIS
# ----------------------------
# rubocop:disable Metrics/AbcSize
def gerar_totais(pdf, total, y_pos)
pdf.move_cursor_to(y_pos)
pdf.move_down 3.mm
Expand Down Expand Up @@ -524,7 +511,6 @@ def gerar_totais(pdf, total, y_pos)
pdf.move_down 40.mm
pdf.cursor
end
# rubocop:enable Metrics/AbcSize

# ----------------------------
# INFORMAÇÕES ADICIONAIS
Expand Down