Class: ODDB::TestInvoiceItem

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_model/invoice.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



117
118
119
# File 'test/test_model/invoice.rb', line 117

def setup
  @item = InvoiceItem.new
end

- (Object) test_dup



151
152
153
154
# File 'test/test_model/invoice.rb', line 151

def test_dup
  dupl = @item.dup
  assert_not_equal @item.data.object_id, dupl.data.object_id
end

- (Object) test_expired



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'test/test_model/invoice.rb', line 134

def test_expired
  assert_equal(true, @item.expired?)
  assert_equal(true, @item.expired?(@@today))
  assert_equal(true, @item.expired?(Time.now))
  @item.time = Time.now
  assert_equal(true, @item.expired?)
  assert_equal(true, @item.expired?(@@today))
  assert_equal(true, @item.expired?(Time.now))
  @item.expiry_time = @@today - 1
  assert_equal(true, @item.expired?)
  assert_equal(true, @item.expired?(@@today))
  assert_equal(true, @item.expired?(Time.now))
  @item.expiry_time = @@today
  assert_equal(false, @item.expired?)
  assert_equal(false, @item.expired?(@@today))
  assert_equal(false, @item.expired?(Time.now))
end

- (Object) test_expiry_time



155
156
157
158
# File 'test/test_model/invoice.rb', line 155

def test_expiry_time
  now = Time.now
  assert_equal now + 5*60*60*24, InvoiceItem.expiry_time(5, now)
end

- (Object) test_init



159
160
161
162
163
164
# File 'test/test_model/invoice.rb', line 159

def test_init
  @item.pointer = Persistence::Pointer.new [:invoice, 2], :item
  @item.init nil
  assert_equal Persistence::Pointer.new([:invoice, 2], [:item, @item.oid]),
               @item.pointer
end

- (Object) test_to_s



165
166
167
168
# File 'test/test_model/invoice.rb', line 165

def test_to_s
  @item.text = 'some item text'
  assert_equal 'some item text', @item.to_s
end

- (Object) test_total_brutto_writer



127
128
129
130
131
132
133
# File 'test/test_model/invoice.rb', line 127

def test_total_brutto_writer
  @item.vat_rate = 100/3.0
  @item.quantity = 1
  @item.total_brutto = 100
  assert_in_delta(75.0, @item.price, 0.01)
  assert_in_delta(25.0, @item.vat, 0.01)
end

- (Object) test_total_netto_writer



120
121
122
123
124
125
126
# File 'test/test_model/invoice.rb', line 120

def test_total_netto_writer
  @item.vat_rate = 100/3.0
  @item.quantity = 10
  @item.total_netto = 100
  assert_equal(10, @item.price)
  assert_in_delta(100/3.0, @item.vat, 0.01)
end

- (Object) test_ydim_data



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'test/test_model/invoice.rb', line 169

def test_ydim_data
  now = Time.now
  expt = Time.now + 24*3600
  @item.data.store :some, :data
  @item.expiry_time = expt 
  @item.price = 100.0
  @item.quantity = 4
  @item.text = 'A Text'
  @item.time = now
  @item.unit = 'Stück'
  @item.vat_rate = 7.6
  expected = {
    :data        => { :some => :data },
    :expiry_time => expt,
    :price       => 100.0,
    :quantity    => 4,
    :text        => 'A Text',
    :time        => now,
    :unit        => 'Stück',
    :vat_rate    => 7.6,
  }
  assert_equal expected, @item.ydim_data
end