gtmtech-crypto 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/gtmtech-crypto.gemspec +1 -1
- data/lib/gtmtech/crypto/data.rb +32 -0
- data/lib/gtmtech/crypto/subcommands/txn.rb +10 -0
- data/lib/gtmtech/crypto/utils.rb +9 -0
- data/lib/gtmtech/crypto.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ed8270eb639f0c6bd3f0e8e9eb246be3d6d5ca
|
4
|
+
data.tar.gz: 577a3a6572ff24224185a41051f19e5f7bb334fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aae2d5056eb65275f79d34389d8ae5020e816ce1fbdd131b78853ae1895692a495f984681a0c95fa1ee75d05118ccfbb615de9a2d066bdbb2d987287d8b2ebd
|
7
|
+
data.tar.gz: 37640e9619beebfcdceae491a6e0da454466ed671d5e3aab3cc4d1c69dbf8696b0596f57ade724a518f4e1adbf50fde4706f0d80ccbf177156d36ce0dc639729
|
data/gtmtech-crypto.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "gtmtech-crypto"
|
7
|
-
gem.version = "0.0.
|
7
|
+
gem.version = "0.0.6"
|
8
8
|
gem.description = "Simple tool for accounting of cryptocurrencies"
|
9
9
|
gem.summary = "Simple tool for accounting of cryptocurrencies"
|
10
10
|
gem.author = "Geoff Meakin"
|
data/lib/gtmtech/crypto/data.rb
CHANGED
@@ -83,6 +83,38 @@ module Gtmtech
|
|
83
83
|
@@document[ "transactions" ].delete( id )
|
84
84
|
end
|
85
85
|
|
86
|
+
def self.reconcile_transactions
|
87
|
+
self.list_transactions
|
88
|
+
puts ""
|
89
|
+
printf("%-20s %-10s %-20s\n", "account", "currency", "amount")
|
90
|
+
puts "-" * 120
|
91
|
+
fees = {}
|
92
|
+
@@document[ "accounts" ].each do | name, account_info |
|
93
|
+
account_info[ "currencies" ].sort.each do | currency |
|
94
|
+
decimal = "0.0"
|
95
|
+
@@document[ "transactions" ].each do |id, txn|
|
96
|
+
if txn[ "fees_account" ] == name and txn[ "fees_currency" ] == currency
|
97
|
+
decimal = Utils.decimal_minus( decimal, txn[ "fees_amount" ] )
|
98
|
+
unless fees.key? currency
|
99
|
+
fees[ currency ] = "0.0"
|
100
|
+
end
|
101
|
+
fees[ currency ] = Utils.decimal_add( fees[currency], txn[ "fees_amount" ])
|
102
|
+
end
|
103
|
+
if txn[ "source_account" ] == name and txn[ "source_currency" ] == currency
|
104
|
+
decimal = Utils.decimal_minus( decimal, txn[ "source_amount" ] )
|
105
|
+
end
|
106
|
+
if txn[ "dest_account" ] == name and txn[ "dest_currency" ] == currency
|
107
|
+
decimal = Utils.decimal_add( decimal, txn[ "dest_amount" ] )
|
108
|
+
end
|
109
|
+
end
|
110
|
+
printf( "%-20s %-10s %-20s\n", name, currency, decimal )
|
111
|
+
end
|
112
|
+
end
|
113
|
+
fees.keys.sort.each do |currency|
|
114
|
+
printf( "%-20s %-10s %-20s\n", "**FEES**", currency, fees[ currency ] )
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
86
118
|
def self.save
|
87
119
|
File.open(@@path, 'w') do |file|
|
88
120
|
file.write( @@document.to_yaml )
|
@@ -20,6 +20,9 @@ crypto #{self.prettyname} new --date=<s> --from=<s> --to=<s> [--fees=<s>]
|
|
20
20
|
crypto #{self.prettyname} delete --id=<s>
|
21
21
|
- delete a transaction
|
22
22
|
|
23
|
+
crypto #{self.prettyname} reconcile
|
24
|
+
- reconcile all transactions
|
25
|
+
|
23
26
|
crypto #{self.prettyname} list
|
24
27
|
- list all transactions
|
25
28
|
|
@@ -106,6 +109,11 @@ EOS
|
|
106
109
|
Data.save
|
107
110
|
end
|
108
111
|
|
112
|
+
def self.reconcile
|
113
|
+
Data.load
|
114
|
+
Data.reconcile_transactions
|
115
|
+
end
|
116
|
+
|
109
117
|
def self.execute
|
110
118
|
verb = ARGV.shift
|
111
119
|
case verb.downcase
|
@@ -115,6 +123,8 @@ EOS
|
|
115
123
|
self.list
|
116
124
|
when "delete"
|
117
125
|
self.delete
|
126
|
+
when "reconcile"
|
127
|
+
self.reconcile
|
118
128
|
else
|
119
129
|
self.error "transaction takes an action [new, list, delete] . See --help for more info"
|
120
130
|
end
|
data/lib/gtmtech/crypto/utils.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'bigdecimal'
|
2
3
|
|
3
4
|
module Gtmtech
|
4
5
|
module Crypto
|
@@ -58,6 +59,14 @@ module Gtmtech
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
62
|
+
def self.decimal_add decimal1, decimal2
|
63
|
+
( BigDecimal( decimal1 ) + BigDecimal( decimal2 ) ).to_s("F")
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.decimal_minus decimal1, decimal2
|
67
|
+
( BigDecimal( decimal1 ) - BigDecimal( decimal2 ) ).to_s("F")
|
68
|
+
end
|
69
|
+
|
61
70
|
end
|
62
71
|
end
|
63
72
|
end
|
data/lib/gtmtech/crypto.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtmtech-crypto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Meakin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|