Class: ODDB::PatinfoInvoicer

Inherits:
InfoInvoicer show all
Defined in:
src/plugin/patinfo_invoicer.rb

Constant Summary

Constants inherited from Invoicer

RECIPIENTS

Constants inherited from Plugin

ARCHIVE_PATH, RECIPIENTS

Instance Method Summary (collapse)

Methods inherited from InfoInvoicer

#active_companies, #adjust_annual_fee, #adjust_company_fee, #adjust_overlap_fee, #all_items, #annual_items, #filter_paid, #group_by_company, #pointer_resolved, #recent_items, #run, #send_annual_invoices, #send_daily_invoices, #slate_items

Methods inherited from Invoicer

#create_invoice, #ensure_yus_user, #resend_invoice, #rp2fr, #send_invoice

Methods inherited from Plugin

#l10n_sessions, #log_info, #recipients, #report, #resolve_link, #update_rss_feeds

Methods included from HttpFile

#http_body, #http_file

Constructor Details

- (PatinfoInvoicer) initialize(*args)

A new instance of PatinfoInvoicer



8
9
10
11
# File 'src/plugin/patinfo_invoicer.rb', line 8

def initialize(*args)
  @infotype = :patinfo
  super
end

Instance Method Details

- (Object) activation_fee



12
13
14
# File 'src/plugin/patinfo_invoicer.rb', line 12

def activation_fee
  PI_UPLOAD_PRICES[:activation]
end

- (Object) active_infos



15
16
17
18
19
20
# File 'src/plugin/patinfo_invoicer.rb', line 15

def active_infos
  @app.active_pdf_patinfos.keys.inject({}) { |inj, key|
    inj.store(key[0,8], 1)
    inj
  }
end

- (Object) html_items(first)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'src/plugin/patinfo_invoicer.rb', line 21

def html_items(first)
  invoiced = {}
  items = []
  last = first >> 12
  @app.companies.each_value { |company|
    if(company.invoice_htmlinfos && company.invoice_date(:patinfo) == first)
      company.registrations.each { |reg|
        if(reg.active?)
          reg.each_sequence { |seq|
            if(seq.public_package_count > 0 && !seq.pdf_patinfo \
               && (patinfo = seq.patinfo.odba_instance) \
               && !invoiced.include?(patinfo))
              invoiced.store(patinfo, true)
              item = AbstractInvoiceItem.new
              item.price = PI_UPLOAD_PRICES[:annual_fee]
              item.text = [reg.iksnr, seq.seqnr].join(' ')
              item.time = Time.now
              item.type = :annual_fee
              item.unit = "Jahresgeb\374hr"
              item.vat_rate = VAT_RATE
              item.item_pointer = seq.pointer
              items.push(item)
            end
          }
        end
      }
    end
  }
  items
end

- (Object) neighborhood_unique_names(item)



51
52
53
54
55
56
57
58
59
60
61
62
# File 'src/plugin/patinfo_invoicer.rb', line 51

def neighborhood_unique_names(item)
  names = [unique_name(item)].compact
  if((ptr = item.item_pointer) && (seq = ptr.resolve(@app)))
    active = seq.pdf_patinfo
    seq.registration.sequences.each_value { |other|
      if(other.pdf_patinfo == active)
        names.push([other.iksnr, other.seqnr].join('_'))
      end
    }
  end
  names.uniq
end

- (Object) parent_item_class



63
64
65
# File 'src/plugin/patinfo_invoicer.rb', line 63

def parent_item_class
  Sequence
end

- (Object) unique_name(item)



66
67
68
69
70
71
72
73
74
# File 'src/plugin/patinfo_invoicer.rb', line 66

def unique_name(item)
  name = item.text
  if(/^[0-9]{5} [0-9]{2}$/u.match(name))
    name.tr(' ', '_')
  elsif((ptr = item.item_pointer) && (seq = ptr.resolve(@app)) \
        && seq.is_a?(Sequence))
    [seq.iksnr, seq.seqnr].join('_')
  end
end