Class: ODDB::View::PayPal::InvoiceItems

Inherits:
HtmlGrid::List show all
Defined in:
src/view/paypal/invoice.rb

Constant Summary

COMPONENTS =
{
  [0,0] =>  :quantity,
  [1,0] =>  :text,
  [2,0] =>  :price,
}
CSS_CLASS =
'invoice top'
CSS_MAP =
{
  [0,0] =>  'list right',
  [1,0] =>  'list',
  [2,0] =>  'list right',
}
LEGACY_INTERFACE =
false
OMIT_HEADER =
true
STRIPED_BG =
false

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Method Summary (collapse)

Instance Method Details



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'src/view/paypal/invoice.rb', line 22

def compose_footer(matrix)
  total_net = [nil, @lookandfeel.lookup(:total_netto), nil, total_netto()]
  vat = [nil, @lookandfeel.lookup(:vat), nil, vat()]
  total = [nil, @lookandfeel.lookup(:total_brutto), nil, total_brutto()]
  @grid.add(total_net, *matrix)
  @grid.add_style('list bg', matrix.at(0), matrix.at(1), 2)
  @grid.add_style('list right bg', *resolve_offset(matrix, [2,0]))
  matrix = resolve_offset(matrix, [0,1])
  @grid.add(vat, *matrix)
  @grid.add_style('list bg', matrix.at(0), matrix.at(1), 2)
  @grid.add_style('list right bg', *resolve_offset(matrix, [2,0]))
  matrix = resolve_offset(matrix, [0,1])
  @grid.add(total, *matrix)
  @grid.add_style('list bg bold', matrix.at(0), matrix.at(1), 2)
  @grid.add_style('list right bg bold', *resolve_offset(matrix, [2,0]))
end

- (Object) format_price(price, currency = nil)



41
42
43
# File 'src/view/paypal/invoice.rb', line 41

def format_price(price, currency=nil)
  @lookandfeel.format_price(price.to_f * 100.0, currency)
end

- (Object) price(model)



44
45
46
# File 'src/view/paypal/invoice.rb', line 44

def price(model)
  format_price(model.total_netto)
end

- (Object) quantity(model)



47
48
49
# File 'src/view/paypal/invoice.rb', line 47

def quantity(model)
  model.quantity.to_i.to_s << ' x'
end

- (Object) text(model)



38
39
40
# File 'src/view/paypal/invoice.rb', line 38

def text(model)
  model.text
end

- (Object) total_brutto



50
51
52
53
54
# File 'src/view/paypal/invoice.rb', line 50

def total_brutto
  format_price(@model.inject(0) { |inj, item|
    inj + item.total_brutto
  }, @session.state.currency || 'EUR')
end

- (Object) total_netto



55
56
57
58
59
# File 'src/view/paypal/invoice.rb', line 55

def total_netto
  format_price @model.inject(0) { |inj, item|
    inj + item.total_netto
  }
end

- (Object) vat



60
61
62
63
64
# File 'src/view/paypal/invoice.rb', line 60

def vat
  format_price @model.inject(0) { |inj, item|
    inj + item.vat
  }
end