GithubHelp home page GithubHelp logo

Comments (4)

danniel avatar danniel commented on June 12, 2024 2

On the other hand, in the Form field the app expects integers between 0 and 100 for percent_of_ownership and, on Task save, the data does not seem to be transformed to the database expected format for share_ratio.

That's why setting a percent_of_ownership to 0 or 1 or 9 works, while 10, 11, 99 raises <class 'decimal.InvalidOperation'> when trying to save data about Owned Buildings.

from asset-declarations.

RaduCStefanescu avatar RaduCStefanescu commented on June 12, 2024

Great point @danniel
The way I see it the share_ratio should be in the form of 33.5 -> meaning 33.5%.
One way to implement this would be to implement a factory of model fields, that get as input just the name of the field. For example in our case, have a factory method that returns share_ratio type of fields, with 'max_digits=3' and 'decimal_places=1'.

from asset-declarations.

catileptic avatar catileptic commented on June 12, 2024

This is great digging and a great summary of the issue!

On the other hand, it occurs to me, reading this, that there might be people who have filled the asset declaration form in with a percent of 89.78. I hope this isn't the case, but what if it is?

Regardless, I think we should address this issue as part of the refactoring needed to merge this PR.

What do you think?

from asset-declarations.

danniel avatar danniel commented on June 12, 2024

I will make all three fields to be max_digits=5, decimal_places=2

This way we can allow values as 100.00 for (100%)
A custom validator will prevent the input of values over 100.00

from asset-declarations.

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.