gobl 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gobl/num/amount.rb +4 -6
- data/lib/gobl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d76cccae7dcefa86ad6553de26fdccdcf1070c86b94397b2afd6fce95973c5d
|
4
|
+
data.tar.gz: b08932429a3dceda76e61fad765e221126542b105b5141cfcac2bbab7df9d9fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 343e9b78a8c5d9e41614345310358b12b64360a2d6da81b52d5e0e03a4f819f045c0caa79772a02a285f6a62f991ff5804298eeaf6e0fe559a56d25c40a2cf01
|
7
|
+
data.tar.gz: d623de76e1c087bc6e391c43e5501ac74a593dadd0e3548ad1649b4955130589164538da7d3454d875f9a19bbc029e73e63cc47c7b5304eb51e0e9d254e8f091
|
data/lib/gobl/num/amount.rb
CHANGED
@@ -50,11 +50,9 @@ module GOBL
|
|
50
50
|
raise 'exponent too high' if exp > 100
|
51
51
|
|
52
52
|
p = 10**exp
|
53
|
-
v1 = value.abs
|
54
|
-
|
55
|
-
|
56
|
-
v2 = -v2 if v2.negative?
|
57
|
-
format('%d.%0*d', v1, exp, v2)
|
53
|
+
v1, v2 = value.abs.divmod(p)
|
54
|
+
sign = value.negative? ? '-' : ''
|
55
|
+
format('%s%d.%0*d', sign, v1, exp, v2)
|
58
56
|
end
|
59
57
|
|
60
58
|
# Rescales each {Amount} in the pair ensuring both have the same exponent
|
@@ -209,7 +207,7 @@ module GOBL
|
|
209
207
|
v2 = x[1].to_i
|
210
208
|
e = x[1].length
|
211
209
|
v *= 10**e
|
212
|
-
v +=
|
210
|
+
v += x[0].match?(/^-/) ? -v2 : v2
|
213
211
|
end
|
214
212
|
|
215
213
|
@value = v
|
data/lib/gobl/version.rb
CHANGED