Class: Abank::Folha

Inherits:
Big
  • Object
show all
Defined in:
lib/abank/folha.rb

Constant Summary

Constants inherited from Big

Big::DF

Instance Attribute Summary collapse

Attributes inherited from Big

#bqnrs, #bqres, #ctpos, #job, #mvpos, #opcao

Instance Method Summary collapse

Methods inherited from Big

#cc_apaga, #cc_cria, #cc_show, #ct_apaga, #ct_cria, #ct_dados, #ct_mostra, #mc_show, #mv_classifica, #mv_delete, #mv_insert, #re_atualiza, #re_insert

Constructor Details

#initialize(opcoes = {}) ⇒ Folha

acesso a folha calculo & base dados abank no bigquery

Parameters:

  • xls (String)

    folha calculo a processar

  • opcoes (Thor::CoreExt::HashWithIndifferentAccess) (defaults to: {})

    trabalho

Options Hash (opcoes):

  • :s (Boolean) — default: false

    apaga movimento similar? (mv)

  • :e (Boolean) — default: false

    apaga movimento igual? (mv)

  • :i (Boolean) — default: false

    insere movimento novo? (mv)

  • :n (Integer) — default: 0

    conta dos movimentos (mv)

  • :v (String) — default: ''

    data valor movimentos (mv)

  • :g (String) — default: ''

    classificacao movimentos (mv)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/abank/folha.rb', line 21

def initialize(opcoes = {})
  super
  @opcao = opcao.merge(
    s: opcoes.fetch(:s, false),
    e: opcoes.fetch(:e, false),
    i: opcoes.fetch(:i, false),
    n: opcoes.fetch(:n, 0),
    v: opcoes.fetch(:v, ''),
    g: opcoes.fetch(:g, ''),
    k: +'',
    f: opcoes[:f]
  )
  @mvvls = []
end

Instance Attribute Details

#mvvlsArray, String (readonly)

Returns:

  • (Array)

    row folha calculo em processamento

  • (String)

    movimentos a inserir (values.mv)



9
10
11
# File 'lib/abank/folha.rb', line 9

def mvvls
  @mvvls
end

#rowfcArray, String (readonly)

Returns:

  • (Array)

    row folha calculo em processamento

  • (String)

    movimentos a inserir (values.mv)



9
10
11
# File 'lib/abank/folha.rb', line 9

def rowfc
  @rowfc
end

Instance Method Details

#processa_xlsObject

carrega/mostra folha calculo



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/abank/folha.rb', line 37

def processa_xls
  puts("\n#{opcao[:f]}")
  mvs = sql("select * from #{BD}.gmv where nc=@nc", nc: conta).group_by { |m| [m[:dl], m[:vl].to_f] }
  folha.sheet(0).parse(header_search: ['Data Lanc.', 'Data Valor', 'Descrição', 'Valor']) do |r|
    next unless valid?(r.values)

    @bqres = mvs[[rowfc[0], rowfc[3]]] || []
    if bqres.empty?
      puts(lnexi)
    elsif bqres.one? && bqres.first[:ds].strip == rowfc[2]
      puts(lexis)
    elsif bqres.one?
      puts(lsiml)
    else
      puts(lmult)
    end
  end
  return unless opcao[:i]

  # para nao apagar movimentos duma conta, por aqui somente com keys opcao[:k]
  opcao[:n] = 0
  mv_delete.mv_insert.ct_dados.re_insert
end