gtmtech-crypto 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gtmtech-crypto.gemspec +1 -1
- data/lib/gtmtech/crypto/data.rb +29 -1
- data/lib/gtmtech/crypto/subcommands/reconcile.rb +41 -0
- data/lib/gtmtech/crypto/subcommands/txn.rb +0 -7
- data/lib/gtmtech/crypto.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9249ed0680a98415b65c2c8a4b0a2a09757c6f39
|
4
|
+
data.tar.gz: fc6c53c8576ce6a614f9a8e4e47ff6b8a3b28280
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b169a5d180010831985fe0a5272f479ac5dc64d56a5018258fa46613e25617541c7b62f5435facef4a5aa15a167fc1e1cea545212471b6c83ff4d8f27bf85e4d
|
7
|
+
data.tar.gz: 0666c0d29a85d7439032af75fa5d5e50520cae9a0af5b3b175692b9a3c57a978f86f8275fd8eddb034217a9b4e464e315da7322e91af31d6cd35066ada588907
|
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.7"
|
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
@@ -89,30 +89,58 @@ module Gtmtech
|
|
89
89
|
printf("%-20s %-10s %-20s\n", "account", "currency", "amount")
|
90
90
|
puts "-" * 120
|
91
91
|
fees = {}
|
92
|
+
currencies = {}
|
92
93
|
@@document[ "accounts" ].each do | name, account_info |
|
93
94
|
account_info[ "currencies" ].sort.each do | currency |
|
94
95
|
decimal = "0.0"
|
95
96
|
@@document[ "transactions" ].each do |id, txn|
|
97
|
+
# explicit fees
|
96
98
|
if txn[ "fees_account" ] == name and txn[ "fees_currency" ] == currency
|
97
99
|
decimal = Utils.decimal_minus( decimal, txn[ "fees_amount" ] )
|
98
100
|
unless fees.key? currency
|
99
101
|
fees[ currency ] = "0.0"
|
100
102
|
end
|
101
|
-
fees[ currency ] = Utils.decimal_add( fees[currency], txn[ "fees_amount" ])
|
103
|
+
fees[ currency ] = Utils.decimal_add( fees[ currency ], txn[ "fees_amount" ])
|
102
104
|
end
|
105
|
+
|
106
|
+
# account reconciliation
|
103
107
|
if txn[ "source_account" ] == name and txn[ "source_currency" ] == currency
|
104
108
|
decimal = Utils.decimal_minus( decimal, txn[ "source_amount" ] )
|
109
|
+
|
110
|
+
# implicit fees
|
111
|
+
if txn[ "source_currency" ] == txn[ "dest_currency" ] and txn[ "source_amount" ] != txn[ "dest_amount" ]
|
112
|
+
implicit_fees = Utils.decimal_minus( txn[ "source_amount" ], txn[ "dest_amount" ] )
|
113
|
+
unless fees.key? currency
|
114
|
+
fees[ currency ] = "0.0"
|
115
|
+
end
|
116
|
+
fees[ currency ] = Utils.decimal_add( fees[ currency ], implicit_fees )
|
117
|
+
end
|
118
|
+
|
105
119
|
end
|
106
120
|
if txn[ "dest_account" ] == name and txn[ "dest_currency" ] == currency
|
107
121
|
decimal = Utils.decimal_add( decimal, txn[ "dest_amount" ] )
|
108
122
|
end
|
109
123
|
end
|
124
|
+
unless currencies.key? currency
|
125
|
+
currencies[ currency ] = "0.0"
|
126
|
+
end
|
127
|
+
currencies[ currency ] = Utils.decimal_add( currencies[ currency ], decimal )
|
110
128
|
printf( "%-20s %-10s %-20s\n", name, currency, decimal )
|
111
129
|
end
|
112
130
|
end
|
113
131
|
fees.keys.sort.each do |currency|
|
132
|
+
unless currencies.key? currency
|
133
|
+
currencies[ currency ] = "0.0"
|
134
|
+
end
|
135
|
+
currencies[ currency ] = Utils.decimal_add( currencies[ currency ], fees[ currency ] )
|
114
136
|
printf( "%-20s %-10s %-20s\n", "**FEES**", currency, fees[ currency ] )
|
115
137
|
end
|
138
|
+
puts ""
|
139
|
+
printf( "%-10s %-20s\n", "currency", "reconciliation" )
|
140
|
+
puts "-" * 120
|
141
|
+
currencies.keys.sort.each do |currency|
|
142
|
+
printf( "%-10s %-20s\n", currency, currencies[ currency ] )
|
143
|
+
end
|
116
144
|
end
|
117
145
|
|
118
146
|
def self.save
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'gtmtech/crypto/subcommand'
|
2
|
+
|
3
|
+
module Gtmtech
|
4
|
+
module Crypto
|
5
|
+
module Subcommands
|
6
|
+
|
7
|
+
class Reconcile < Subcommand
|
8
|
+
|
9
|
+
def self.description
|
10
|
+
"reconcile transactions"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.usage
|
14
|
+
<<-EOS
|
15
|
+
Usage (crypto #{self.prettyname})
|
16
|
+
|
17
|
+
crypto #{self.prettyname}
|
18
|
+
- reconcile all transactions
|
19
|
+
|
20
|
+
Options:
|
21
|
+
EOS
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.options
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.reconcile
|
29
|
+
Data.load
|
30
|
+
Data.reconcile_transactions
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.execute
|
34
|
+
self.reconcile
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -109,11 +109,6 @@ EOS
|
|
109
109
|
Data.save
|
110
110
|
end
|
111
111
|
|
112
|
-
def self.reconcile
|
113
|
-
Data.load
|
114
|
-
Data.reconcile_transactions
|
115
|
-
end
|
116
|
-
|
117
112
|
def self.execute
|
118
113
|
verb = ARGV.shift
|
119
114
|
case verb.downcase
|
@@ -123,8 +118,6 @@ EOS
|
|
123
118
|
self.list
|
124
119
|
when "delete"
|
125
120
|
self.delete
|
126
|
-
when "reconcile"
|
127
|
-
self.reconcile
|
128
121
|
else
|
129
122
|
self.error "transaction takes an action [new, list, delete] . See --help for more info"
|
130
123
|
end
|
data/lib/gtmtech/crypto.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Meakin
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- lib/gtmtech/crypto/subcommand.rb
|
47
47
|
- lib/gtmtech/crypto/subcommands/account.rb
|
48
48
|
- lib/gtmtech/crypto/subcommands/help.rb
|
49
|
+
- lib/gtmtech/crypto/subcommands/reconcile.rb
|
49
50
|
- lib/gtmtech/crypto/subcommands/txn.rb
|
50
51
|
- lib/gtmtech/crypto/subcommands/unknown_command.rb
|
51
52
|
- lib/gtmtech/crypto/subcommands/version.rb
|