istox 0.3.7 → 0.3.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75e10cb6d1dcb5bd74c997b76132f60584a5b972baefa437afe9f9f0029dcab5
4
- data.tar.gz: af131f006db3f2e7f8c12dec31a96baf744a0e5ac0680db6219271a89bc8e753
3
+ metadata.gz: '08ae3c962e156368285e8e07ea655d428b93310ab4137a370dd6ab95f7ac00cc'
4
+ data.tar.gz: 6f6c813fee420de9cd06e0175069e8f8f2e3b2d70eebe8e792962f3cac419190
5
5
  SHA512:
6
- metadata.gz: 2f4240480155f92db200cd0300f85b97e46c1f3ee0d3901d12bd1266d7c40ac2f988f0700f7252097310b2ef56fd66b18d3a4346a002d282ae5e7056f816200d
7
- data.tar.gz: 9bae4b48b56fd7f6c193091cb3239c321e782605b12163dd900029cf258edae567eca0d7687468ce182f373803b0d419c9994a1786f36348747f317f974cc14d
6
+ metadata.gz: 534957ad873114132ca7fb35d79570f72c6020785d8bb7b71d7935fd98e6d2cb42d82166270dacdc6cf0f44dc8b649af80ec9724e2f022ce3646b0cbdf950a35
7
+ data.tar.gz: 945b8a9e2bf22dfccd62c2a0c7a3d38cf0c682c095d8ef28ddcfa66f74388e7891e31389b986c0351537cf061cb4c54c8ae789957d3f1492a349b65170b1071f
@@ -10,8 +10,8 @@ module Istox
10
10
  input = ::BigDecimal.new(input.to_s).round(precision, round_mode)
11
11
 
12
12
  input = input.abs if abs_num
13
-
14
- result = format("%.#{precision}f", input)
13
+ # result = format("%.#{precision}f", input) # may produce floating point error
14
+ result = (input.truncate(precision).to_s('F') + '000000000000000000')[/.*\..{#{precision}}/]
15
15
 
16
16
  parts = result.to_s.split('.')
17
17
  parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, '\\1,')
@@ -19,7 +19,7 @@ module Istox
19
19
  end
20
20
 
21
21
  # format a money, eg. 20000.134 > SGD 20,000.14, position can be :front or :behind, abs_num: whether to absolute the number
22
- def money(input, round_mode: :half_up, precision: nil, currency:, position: :front, abs_num: false, hide_currency: false)
22
+ def money(input, currency:, round_mode: :half_up, precision: nil, position: :front, abs_num: false, hide_currency: false)
23
23
  # precision = ::Istox::CommonHelper.get_currency_decimal(currency, precision)
24
24
 
25
25
  decimal_place = if precision.present?
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.3.7'.freeze
2
+ VERSION = '0.3.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-13 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print
@@ -505,7 +505,7 @@ files:
505
505
  homepage: http://www.abc.com
506
506
  licenses: []
507
507
  metadata: {}
508
- post_install_message:
508
+ post_install_message:
509
509
  rdoc_options: []
510
510
  require_paths:
511
511
  - lib
@@ -520,8 +520,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
520
520
  - !ruby/object:Gem::Version
521
521
  version: '0'
522
522
  requirements: []
523
- rubygems_version: 3.2.11
524
- signing_key:
523
+ rubygems_version: 3.0.6
524
+ signing_key:
525
525
  specification_version: 4
526
526
  summary: istox backend shared gem
527
527
  test_files: []