Skip to content

Commit

Permalink
do not make assumptions on fee signs (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
frantisekrokusek authored Nov 8, 2023
1 parent fbe163b commit 944b554
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cfonb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions lib/cfonb/operation_detail/fee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/cfonb/operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 944b554

Please sign in to comment.