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

Refactor currency handling to use pesa #268

Merged
merged 25 commits into from
Jan 11, 2022
Merged

Conversation

18alantom
Copy link
Member

@18alantom 18alantom commented Dec 2, 2021

Currency Refactor

PR pertains to refactoring books to use pesa to handle monetary calculations.

Pesa initialization

  1. Initialized immediately after db connect.
  2. If setup is incomplete currency is not available; ∴ initialized with default "XXX" code for no currency.
  3. if setup incomplete, on submit with the entered currency.

Todo List

  • All javascript calculations should take place through pesa methods.
  • All sql queries should cast the values to number first.
  • Deprecate earlier handling of precision.
  • Setting display should change the number of significant digits displayed.
  • On storing the values in the db, use string type and use Money#store
    which will get a precision adjusted decimal string.
  • When a doc is being fetched the currency values should be converted to the
    Money object.
  • Patch that converts values to store strings.
  • After db init when currency and internalPrecision are available set pesa on
    the global object.

Other Changes

  • Model#field#validate(value, doc) will be called before update in Base.vue on blurring of the input field. Validations will be inline, previous change has been removed cause they are called on doc.set.
Screen.Recording.2022-01-10.at.13.46.10.mov
  • This function should throw an error if invalid, this will be show in a message box.
  • Int and Float types now have number inputs, Model#field#minValue and Model#field#maxValue can be used to restrict the range.
  • Added Locale in System Settings to set Intl.NumberFormat

FrappeJS: frappe/frappejs#153

@18alantom 18alantom changed the title refactor: shift pesa init with currency to books Refactor currency handling to use pesa Dec 2, 2021
@18alantom
Copy link
Member Author

18alantom commented Dec 24, 2021

All builds are gonna fail cause they're dependent on the make-money branch of frappejs.

@18alantom 18alantom force-pushed the make-money branch 2 times, most recently from afbcbcf to 65b1a05 Compare December 31, 2021 06:36
@18alantom 18alantom marked this pull request as ready for review December 31, 2021 08:20
@18alantom
Copy link
Member Author

Merging this should close #284 and #185

@18alantom 18alantom merged commit 6a9fd90 into frappe:master Jan 11, 2022
@18alantom 18alantom deleted the make-money branch January 11, 2022 06:04
This was referenced Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants