farmingengineers 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{farmingengineers}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Burke"]
12
- s.date = %q{2010-10-17}
12
+ s.date = %q{2010-10-18}
13
13
  s.description = %q{Invoice generators, etc.}
14
14
  s.email = %q{mr.matt.burke@gmail.com}
15
15
  s.extra_rdoc_files = [
data/invoice.rb CHANGED
@@ -7,7 +7,8 @@ egg_csa_invoice do
7
7
  customer 'Sample customer'
8
8
  address ['123 Street', 'City, IN', '317-xxx-xxxx']
9
9
  deposit '8/1/2010', 50
10
- deliver '10/11/2010', 4
10
+ deliver '10/11/2010', 11
11
+ deliver '10/11/2010', 4, :rate => 4.50
11
12
  purchase '11/1/2010', 'Doughnuts', 10
12
13
  notes 'Notes to customer'
13
14
  end
@@ -15,6 +15,7 @@ def egg_csa_invoice(&block)
15
15
  balance += line.total
16
16
  t << [line.date, line.description, line.quantity, d(line.total), d(balance)]
17
17
  end
18
+ t << ['', '', '', 'TOTAL', d(balance)]
18
19
  end
19
20
 
20
21
  history_table.rename_columns(
@@ -7,25 +7,29 @@ module FarmingEngineers ; module Invoices ; module Eggs
7
7
  end
8
8
 
9
9
  class History < Common::History
10
- def deliver date, dozens
11
- push Delivery.new(date, dozens)
10
+ def deliver date, dozens, opts = {}
11
+ push Delivery.new(date, dozens, opts)
12
12
  end
13
13
  end
14
14
 
15
15
  class Delivery < Common::HistoryItem
16
- def initialize(date, dozens)
16
+ def initialize(date, dozens, opts = {})
17
17
  @date = date
18
18
  @description = 'Delivery'
19
19
  @quantity = dozens
20
+ @total = calculate opts.merge(:dozens => dozens)
20
21
  end
21
- def total
22
- if @quantity < 8
23
- @quantity * 5
24
- elsif @quantity < 12
25
- @quantity * 4.50
26
- else
27
- @quantity * 4
28
- end
22
+ private
23
+ def calculate opts
24
+ opts[:total] ||
25
+ opts[:dozens] * (opts[:rate] || opts[:price] ||
26
+ if opts[:dozens] < 8
27
+ 5
28
+ elsif opts[:dozens] < 12
29
+ 4.50
30
+ else
31
+ 4
32
+ end)
29
33
  end
30
34
  end
31
35
  end ; end ; end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farmingengineers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Burke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-17 00:00:00 -04:00
18
+ date: 2010-10-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency