Giter Club home page Giter Club logo

Comments (2)

Nihantra-Patel avatar Nihantra-Patel commented on June 16, 2024

Because validation already set:

def check_conversion_rate(self):
default_currency = erpnext.get_company_currency(self.company)
if not default_currency:
throw(_("Please enter default currency in Company Master"))
if (
(self.currency == default_currency and flt(self.conversion_rate) != 1.00)
or not self.conversion_rate
or (self.currency != default_currency and flt(self.conversion_rate) == 1.00)
):
throw(_("Conversion rate cannot be 0 or 1"))

It's responsible for checking the validity of a conversion rate between currencies. Here's what it does:

  1. It first gets the default currency of the company where the transaction is occurring.
  2. Then it checks if there is a default currency set for the company. If not, it throws an error asking the user to enter the default currency.
  3. Next, it evaluates three conditions:
    a. If the currency of the transaction matches the default currency and the conversion rate is not 1, or if there's no conversion rate specified.
    b. If the currency of the transaction doesn't match the default currency and the conversion rate is 1.
    If any of these conditions are met, it throws an error stating that the conversion rate cannot be 0 or 1.

In simpler terms, the code ensures that the conversion rate between currencies is valid. It checks if the conversion rate is neither 0 nor 1, and it makes sure that the conversion rate is specified when the currencies involved are different from the default currency of the company.

from erpnext.

nabinhait avatar nabinhait commented on June 16, 2024

As this is applicable to a very rare use-case, we have decided to keep the validation. You can bypass the validation by overriding the function, closing the issue.

from erpnext.

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.