Code Monkey home page Code Monkey logo

Comments (7)

Betree avatar Betree commented on September 26, 2024

#7010 might be a requirement for this

from opencollective.

Betree avatar Betree commented on September 26, 2024

For this week:

  • Call with @aerugo to kickstart project
  • Create initial specs
  • Start development

from opencollective.

Betree avatar Betree commented on September 26, 2024

Specs

Resolving this issue without #7010 would be clanky, as we'd have to make sure all items share the same FX rate when using the same currency (which might be wrong, for example if items are not from the same date) and store this information in inappropriate places. The specs proposed below therefore address both issues.

API

  • In the ExpenseItem model
    • Add a currency field (string)
    • Add a fxRate field (float, the FX rate between the expense and the item)
    • Add a fxRateSource field (enum<OPENCOLLECTIVE|PAYPAL|WISE|USER> who provided this FX rate)
  • Expose this information on the ExpenseItem GraphQL object
  • Add the appropriate fields to ExpenseItemInput/ExpenseItemCreateInput
  • Update the code in createExpense/editExpense to support this.
    • createExpense
    • editExpense
    • Make sure that we keep verifying that expense.amount = SUM(expenseItem.amount) by converting the expense items amounts using the provided FX rates.
    • If the user-provided FX rate is too far from what we have in the DB, throws an error.
  • In the uploadFile mutation (that returns the OCR results):
    • Add a parsingOptions (object) argument
    • parsingOptions.currency: target currency to return the OCR results for
    • If this currency was set, use it for the generated ParseUploadedFileResult, to make sure it updates all the children amounts (in ExpenseParsedFileInfo and ExpenseItemParsedFileInfo) are converted to the target currency.
    • Ideally, try to generate the FX rate for the date returned by OCRParseResult.date
  • In GraphQLCurrencyExchangeRateSourceType, add a USER value to acknowledge that FX rates can now be user-submitted
  • Add an endpoint to dynamically fetch multiple currency rates (for when the currency of the expense or an item changes)

Frontend

  • In the expense form
    • When uploading expense items, make sure to fetch these new amount & exchange rate fields
    • In AmountInput, implement the ability to view the amount in both currencies (based on a given exchange rate), as surfaced in the design below. We don't want to show country flags for now.
      image
    • Let the user change the amount in whatever currency. The one of the left stays the source of truth, so changing the amount on the right only affects the exchange rate.
    • Below the amount, add the explicit exchange rate, along with a link to manually set one.
      image
    • The info tooltip should say: Currency exchange rate from {source}, as of {date}. If you have a more accurate information, please enter it.
    • Implement a strategy for when the expense currency changes
    • When an item's currency changes, make sure to update the amount with a proper FX rate
  • When viewing the expense
    • Make sure to display the FX rate source and value along with the original amount
  • Make sure that the new GraphQLCurrencyExchangeRateSourceType.USER is properly internationalized.

Ideas & Questions

  • Does Klippa support parsing the FX rate from documents? If yes, then we should use this value by default.
  • We may want to add security checks/warnings/error prevention by checking if the fx rate looks legit (based on deviation from DB value)

from opencollective.

Betree avatar Betree commented on September 26, 2024

For this week:

from opencollective.

Betree avatar Betree commented on September 26, 2024

For this week:

  • Iterate on frontend proposal, post a new demo for feedback
  • Cleanup the code to get it in a reviewable state

from opencollective.

Betree avatar Betree commented on September 26, 2024

This week:

  • Iterate on E2E tests (we realized the CI config for E2E was not matching dev)
  • Merge & deploy frontend + API

from opencollective.

Betree avatar Betree commented on September 26, 2024

Done & released!

from opencollective.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.