-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add vat number #2764
feat: add vat number #2764
Conversation
07a0af1
to
91d6c7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some feedback, Mostly questions.
@@ -60,6 +60,9 @@ <h3 style="color: #000000; font-size: 16px; font-weight: 700; line-height: 18px; | |||
</table> | |||
{% endif %} | |||
<strong style="font-weight: 700;">Email Address:</strong> {{ purchaser.email }}<br> | |||
{% if purchaser.vat_id %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we place it behind the tax display feat flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is related to the taxes feature as it was an extra thing required to avoid some manual work. @cachob What are your thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a separate issue from country taxes. A learner may be required to enter a VAT number (by the employer for example) but the country itself may not require a learner's tax
migrations.AddField( | ||
model_name="legaladdress", | ||
name="vat_id", | ||
field=models.CharField(blank=True, max_length=255, null=True), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any possibility of adding a validator on Vat ID if there is one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that initially but there seemed to be no pattern as it varies country to country. Here is what Wikipedia says about vat ids https://en.wikipedia.org/wiki/VAT_identification_number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cachob Do we have a specific pattern that we can validate? Is there a specific length or do we have any specific type of characters that can be used to validate a VAT ID?
As of now, Learners can add anything up to 255 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's be able to accommodate a wide array of formats and lengths. The VAT number formats and lengths may vary from country to country. However, maybe set a character limit lower than 255?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cachob How about setting it to 50 characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a limit of 30 characters in 52e3aeb. I saw some examples and it appeared to be at max 12-13 characters so I went for 30 to be safe.
@@ -51,6 +51,10 @@ export const legalAddressValidation = yup.object().shape({ | |||
.trim() | |||
.matches(NAME_REGEX, NAME_REGEX_FAIL_MESSAGE) | |||
.required(), | |||
vat_id: yup | |||
.string() | |||
.label("VAT ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add min/max limits to the field here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by min/max limits like the character limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 52e3aeb.
@@ -117,6 +118,10 @@ describe("ReceiptPage", () => { | |||
inner.find("#purchaserEmail").text(), | |||
receiptObject.purchaser.email | |||
) | |||
assert.equal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add a test to check that the Vat ID field is hidden when there is no vat id associated with purchaser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 3fecf1f
@@ -14,12 +14,12 @@ import queries from "../../../lib/queries" | |||
import EditProfileForm from "../../../components/forms/EditProfileForm" | |||
|
|||
import type { Response } from "redux-query" | |||
import type { Country, CurrentUser, User } from "../../../flow/authTypes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are using the EditProfile page for both the register and actual edit profile flow. In this case, I think the usage of LoggedInUser
might be problematic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EditProfilePage is only used for the user profile. RegisterDetailsPage and RegisterExtraDetailsPage are used for the registration flow. So, we can use LoggedInUser here.
@@ -176,6 +184,23 @@ export const LegalAddressFields = ({ | |||
/> | |||
<ErrorMessage name="name" component={FormError} /> | |||
</div> | |||
{isVatEnabled ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should write a test for this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just the fields used in RegisterDetailsPage and EditProfilePage. We handled tests for this in the respective pages i.e. RegisterDetailsPage and EditProfilePage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we do not have any existing tests for ProfileFormFields.js. I assume all of the tests are meant to be added for the pages themselves.
3fecf1f
to
52e3aeb
Compare
This is ready for a re-review @arslanashraf7. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 I'm approving this with a couple of questions:
- Do we want to persist the VAT ID per order? - This is not happening right now. Currently, If a user changes or removed the VAT ID later on it would reflect that on the receipt page.
Add VAT
button is not a toggle, Once the user has displayed the field there is no button to hide it again on the profile page. Do we want it to be a real toggle?- If the user removed the VAT ID, The label shows as empty on the profile page and hides completely. Do we want to keep these in-sync?
Yes, there wasn't any requirement to associate it with an order. @cachob might be the best person to comment on this.
@mbilalmughal What is your opinion on this? I have implemented it as per the designs and the designs were approved by everyone.
This is done as per the requirements. |
Merging this one. We will do any updates in follow-up PRs. |
Pre-Flight checklist
What are the relevant tickets?
(Required)
Closes #2762
What's this PR do?
(Required)
Adds a new field
vat_id
in the legal address model. Users can add VAT ID while creating an account and edit from the profile page. Also, Adds it to the receipts.How should this be manually tested?
(Required)
Add VAT ID
and verify that you can see the VAT ID Field.Add VAT ID
toggle.Screenshots