gnucash-invoice 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -22,6 +22,14 @@ List all invoices that can be printed:
22
22
  Print out invoice by it's number:
23
23
 
24
24
  $ gnucash-invoice --dbpath /path/to/db.sqlite3 00004 > invoice-00004.html
25
+
26
+ Here's how generated invoice will look like:
27
+
28
+ ---
29
+
30
+ ![Example](https://pbs.twimg.com/media/A_PnovSCYAAsQBy.png:large)
31
+
32
+ ---
25
33
 
26
34
 
27
35
  ## TODO
@@ -3,6 +3,7 @@ require 'gnucash'
3
3
  require 'gnucash/invoice/version'
4
4
  require 'gnucash/invoice/entry'
5
5
  require 'gnucash/invoice/customer'
6
+ require 'gnucash/invoice/currency'
6
7
  require 'gnucash/invoice/supplier'
7
8
  require 'gnucash/invoice/printer'
8
9
  require 'gnucash/invoice/runner'
@@ -44,6 +45,11 @@ module GnuCash
44
45
  end
45
46
 
46
47
 
48
+ def currency
49
+ @currency ||= Currency.find @raw[:currency]
50
+ end
51
+
52
+
47
53
  def total
48
54
  entries.inject(0){ |memo,entry| memo + entry.total }
49
55
  end
@@ -0,0 +1,33 @@
1
+ module GnuCash
2
+ class Invoice
3
+ class Currency
4
+
5
+ attr_reader :raw, :mnemonic
6
+
7
+
8
+ def initialize data
9
+ @raw = data
10
+
11
+ @mnemonic = data[:mnemonic]
12
+ end
13
+
14
+ alias :to_s :mnemonic
15
+
16
+ def self.find guid
17
+ unless data = dataset.where(:guid => guid).first
18
+ raise CurrencyNotFound, "GUID: #{guid}"
19
+ end
20
+
21
+ new(data)
22
+ end
23
+
24
+
25
+ private
26
+
27
+
28
+ def self.dataset
29
+ GnuCash.connection[:commodities]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  module GnuCash
2
2
  class Invoice
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -44,8 +44,8 @@ html
44
44
  td = entry.description
45
45
  td = entry.action
46
46
  td.quant = "%0.2f" % entry.quantity
47
- td.price = " %0.2f" % entry.price
48
- td.price = " %0.2f" % entry.total
47
+ td.price = "#{invoice.currency} %0.2f" % entry.price
48
+ td.price = "#{invoice.currency} %0.2f" % entry.total
49
49
  tr.total
50
50
  td colspan=5 TOTAL
51
- td.price = " %0.2f" % invoice.total
51
+ td.price = "#{invoice.currency} %0.2f" % invoice.total
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnucash-invoice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-12-29 00:00:00.000000000 Z
14
+ date: 2013-07-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sequel
@@ -127,6 +127,7 @@ files:
127
127
  - gnucash-invoice.gemspec
128
128
  - lib/gnucash.rb
129
129
  - lib/gnucash/invoice.rb
130
+ - lib/gnucash/invoice/currency.rb
130
131
  - lib/gnucash/invoice/customer.rb
131
132
  - lib/gnucash/invoice/entry.rb
132
133
  - lib/gnucash/invoice/printer.rb
@@ -161,6 +162,6 @@ rubyforge_project:
161
162
  rubygems_version: 1.8.23
162
163
  signing_key:
163
164
  specification_version: 3
164
- summary: gnucash-invoice-0.1.0
165
+ summary: gnucash-invoice-0.1.1
165
166
  test_files: []
166
167
  has_rdoc: