From 08edac1b9fc07ffbe3502b264639a16e7874ca27 Mon Sep 17 00:00:00 2001 From: Frantisek ROKUSEK Date: Wed, 8 Nov 2023 17:45:27 +0100 Subject: [PATCH 1/2] do not make assumptions on fee signs --- lib/cfonb/operation_detail/fee.rb | 3 +-- spec/cfonb/operation_spec.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/cfonb/operation_detail/fee.rb b/lib/cfonb/operation_detail/fee.rb index dc7790c..d4b4f2a 100644 --- a/lib/cfonb/operation_detail/fee.rb +++ b/lib/cfonb/operation_detail/fee.rb @@ -8,9 +8,8 @@ class FEE def self.apply(operation, line) operation.fee_currency = line.detail[0..2] scale = line.detail[3].to_i - sign = operation.amount <=> 0 # the detail amount is unsigned - operation.fee = sign * BigDecimal(line.detail[4..17]) / (10**scale) + operation.fee = BigDecimal(line.detail[4..17]) / (10**scale) end CFONB::OperationDetail.register('FEE', self) diff --git a/spec/cfonb/operation_spec.rb b/spec/cfonb/operation_spec.rb index b5428f5..52b14d6 100644 --- a/spec/cfonb/operation_spec.rb +++ b/spec/cfonb/operation_spec.rb @@ -159,7 +159,7 @@ operation.merge_detail(detail) expect(operation.fee_currency).to eq('EUR') - expect(operation.fee).to eq(-7.4) + expect(operation.fee).to eq(7.4) end end end From 9fb6f55bff24f4608b838a4a2915c14b5159cf6b Mon Sep 17 00:00:00 2001 From: Frantisek ROKUSEK Date: Wed, 8 Nov 2023 17:49:06 +0100 Subject: [PATCH 2/2] bump gem version --- cfonb.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfonb.gemspec b/cfonb.gemspec index 5f84c71..bb45117 100644 --- a/cfonb.gemspec +++ b/cfonb.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'cfonb' - s.version = '0.0.4' + s.version = '0.0.5' s.required_ruby_version = '>= 3.2.2' s.summary = 'CFONB parser' s.description = 'An easy to use CFONB format parser'