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

fix: address filter and quotation to for prospect #41040

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Nihantra-Patel
Copy link
Contributor

Version 15

fixes: #41015

Before:

  • When choosing "quotation_to" as a customer, the customer displays correctly. Similarly, when selecting "quotation_to" as the lead, the lead displays correctly. However, when "quotation_to" is set as a prospect, the lead list is shown instead. Moreover, when initially selecting "quotation_to" as a customer and then changing it to prospect, it displays properly.

  • In the case where "quotation_to" is set as a prospect, the address does not appear, and the address filter does not correspond to the prospect; instead, it shows the lead address.

before_prospect_quot.mp4

After:

  • fix the issue, so please check the video.
after_prospect_quot.mp4

@github-actions github-actions bot added accounts needs-tests This PR needs automated unit-tests. labels Apr 16, 2024
frappe.dynamic_link = {
doc: this.frm.doc,
fieldname: "party_name",
doctype: doc.quotation_to == "Customer" ? "Customer" : "Lead",
doctype: doctype,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just do:

doctype: doc.quotation_to?

Futureproof.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code snippet uses a series of if and else if statements to explicitly set the variable doctype based on the value of doc.quotation_to. This approach clearly handles each case ("Customer," "Lead," "Prospect") individually, and it's easy to read and modify.

The suggested alternative in your question (doctype: doc.quotation_to == "Customer" ? "Customer" : "Lead") is not equivalent because it only checks if doc.quotation_to is "Customer" and incorrectly defaults to "Lead" without verifying if it should indeed be "Lead." This misses cases like "Prospect" and any other potential values.

Using a ternary operator for this purpose can lead to errors or reduced clarity, especially when multiple conditions are involved. The original method using if-else statements is more appropriate here for clarity and accuracy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you misunderstand me. There is no need to do an if-else or ternary operator, because quotation_to can only be the values in the Select field anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so a filtered Link field rather than Select, but same effect.
I don't need to try it, it can only be these values:
Screen Shot 2024-04-30 at 18 20 35

@casesolved-co-uk
Copy link
Contributor

@Nihantra-Patel nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accounts needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quotation address does not cater for Prospect
2 participants