-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exchange_rate
to operation
#12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👌
lib/cfonb/operation_detail/mmo.rb
Outdated
@@ -14,6 +14,7 @@ def self.apply(operation, line) | |||
sign = operation.amount <=> 0 # the detail amount is unsigned | |||
|
|||
operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale) | |||
operation.exchange_rate = BigDecimal(line.detail[-4..-1]) / 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/cfonb/operation_detail/mmo.rb
Outdated
@@ -14,6 +14,7 @@ def self.apply(operation, line) | |||
sign = operation.amount <=> 0 # the detail amount is unsigned | |||
|
|||
operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale) | |||
operation.exchange_rate = BigDecimal(line.detail[-4..-1]) / 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operation.exchange_rate = BigDecimal(line.detail[-4..-1]) / 1000 | |
operation.exchange_rate = BigDecimal(line.detail[18..52]) / 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 18..52
?
not 26..29
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake is should have been this 18..69
You are taking the assumption from 1 single example but the documentation states the last section size is 52 starting position 67-49 = 18
lib/cfonb/operation_detail/mmo.rb
Outdated
exchange_rate_value = line.detail[26..29] | ||
operation.exchange_rate = BigDecimal(exchange_rate_value) / 1000 if exchange_rate_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are missing the scale of the exchange rate also
exchange_rate_value = line.detail[26..29] | |
operation.exchange_rate = BigDecimal(exchange_rate_value) / 1000 if exchange_rate_value | |
exchange_rate_value = line.detail[26..29] | |
exchange_rate_scale = line.detail[18] | |
operation.exchange_rate = BigDecimal(exchange_rate_value) / (10**exchange_rate_scale) if exchange_rate_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frantisekrokusek make sense. thank
code is updated
@@ -14,6 +14,11 @@ def self.apply(operation, line) | |||
sign = operation.amount <=> 0 # the detail amount is unsigned | |||
|
|||
operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale) | |||
exchange_rate_value = line.detail[26..29] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can still be wrong but ok to keep it like that for now
Some Sobank statements include exchange rate. We need to parse the value and apply to a transaction.