Skip to content
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

(2931/1) Model a financial value from a csv #2284

Merged
merged 1 commit into from Jan 4, 2024

Conversation

mec
Copy link
Collaborator

@mec mec commented Dec 20, 2023

To try and simplify our approach to importing from csv files this
Import::Csv::Financial class is a basic wrapper for a financial value
that is to be imported from csv.

Our philosophy when importing from csv is that a financial value is to expect:

  • a positive number
  • a negatvie number
  • zero
  • any kind of blank space
  • invalid
  • some kind of financial formatting e.g. 10,000.00

Here, invalid means

We could not convert the supplied string to a BigDecimal.

This implementation treats a 0 and an empty cell the same,
which makes the upstream import code more approachable as we can
assume everything will be 0.

We resue the existing ConvertFinancialValue service object to do the
actual conversion, dealing with an errors as described above - we chose
this approach over changing the ConvertFinancialValue to keep the
changes isolated to the current work.

When we use this class during import, we can expect a financial value to
be one of three states:

  • a BigDecimal value
  • a zero
  • nil

Where nil means it could not be converted.

We also retain the original string value from the csv so it can be
presented back to the user in any error messages.

This work is the first in a series which I hope will:

  • allow users to upload an 'activity commnet' as part of the actual/refund upload
  • refactor the actual/refund import

Next step: model the rest of the attributes in a row along with the financial values using this new model.

If you want more context about the longer plan - just ask! :)

https://trello.com/c/lBZkYq5c

@mec mec force-pushed the feature/2931-model-csv-financial-values branch from 6a145ce to 537c4cf Compare December 20, 2023 13:46
@mec mec changed the title (2931) Model a financial value from a csv (2931/1) Model a financial value from a csv Dec 20, 2023
@mec mec force-pushed the feature/2931-model-csv-financial-values branch 4 times, most recently from 629004d to 100061b Compare January 2, 2024 12:30
To try and simplify our approach to importing from csv files this
Import::Csv::Financial class is a basic wrapper for a financial value
that is to be imported from csv.

Our philosophy when importing from csv is that a financial value is to expect:

- a positive number
- a negatvie number
- zero
- any kind of blank space
- invalid
- some kind of financial formatting e.g. 10,000.00

Here, invalid means

> We could not convert the supplied string to a BigDecimal.

This implementation treats a `0` and an empty cell the same,
which makes the upstream import code more approachable as we can
assume everything will be `0`.

We resue the existing `ConvertFinancialValue` service object to do the
actual conversion, dealing with an errors as described above - we chose
this approach over changing the `ConvertFinancialValue` to keep the
changes isolated to the current work.

When we use this class during import, we can expect a financial value to
be one of three states:

- a BigDecimal value
- a zero
- nil

Where nil means it could not be converted.

We also retain the original string value from the csv so it can be
presented back to the user in any error messages.
@mec mec merged commit f385b94 into develop Jan 4, 2024
3 checks passed
@mec mec deleted the feature/2931-model-csv-financial-values branch January 4, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants