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

feat: add vat number #2764

Merged
merged 14 commits into from
Dec 26, 2023
Merged

feat: add vat number #2764

merged 14 commits into from
Dec 26, 2023

Conversation

asadali145
Copy link
Contributor

@asadali145 asadali145 commented Sep 21, 2023

Pre-Flight checklist

  • Screenshots and design review for any changes that affect layout or styling
    • Desktop screenshots
  • Migrations
    • Migration is backwards-compatible with current production code
  • Testing
    • Code is tested
    • Changes have been manually tested

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)

  • Create a new account and verify that you can see a field toggle for VAT ID under Full Name.
  • Click Add VAT ID and verify that you can see the VAT ID Field.
  • Add some VAT ID and complete account creation.
  • Visit the profile page and see that you can view the VAT ID in profile page.
  • Click to edit the profile page. VAT ID Field should be visible in case VAT ID is added otherwise you will see a Add VAT ID toggle.
  • Enroll in a course and complete payment/ use Coupon.
  • Verify that VAT ID is added in Email Receipt and Dashboard Receipt.
  • Verify that VAT ID is synced with HubSpot

Screenshots

Screen Shot 2023-12-04 at 4 20 06 PM
Screen Shot 2023-12-04 at 4 20 11 PM
Screen Shot 2023-12-04 at 4 20 54 PM
Screen Shot 2023-12-04 at 4 21 22 PM
Screen Shot 2023-12-04 at 4 21 49 PM
Screen Shot 2023-12-04 at 4 22 25 PM
Screen Shot 2023-12-04 at 4 22 55 PM

Copy link
Contributor

@arslanashraf7 arslanashraf7 left a 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 %}
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link

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),
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link

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?

Copy link
Contributor Author

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?

Copy link

Choose a reason for hiding this comment

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

Sounds good to me

Copy link
Contributor Author

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")
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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(
Copy link
Contributor

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.

Copy link
Contributor Author

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"
Copy link
Contributor

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.

Copy link
Contributor Author

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 ? (
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@asadali145
Copy link
Contributor Author

This is ready for a re-review @arslanashraf7.

Copy link
Contributor

@arslanashraf7 arslanashraf7 left a 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:

  1. 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.
  2. 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?
  3. 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?

@asadali145
Copy link
Contributor Author

Do we want to persist the VAT ID per order? - This is not happening right now. Currently, If a user changes or removes the VAT ID later on it would reflect that on the receipt page.

Yes, there wasn't any requirement to associate it with an order. @cachob might be the best person to comment on this.

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?

@mbilalmughal What is your opinion on this? I have implemented it as per the designs and the designs were approved by everyone.

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?

This is done as per the requirements.

@asadali145
Copy link
Contributor Author

Merging this one. We will do any updates in follow-up PRs.

@asadali145 asadali145 merged commit f3ece1e into master Dec 26, 2023
3 checks passed
@odlbot odlbot mentioned this pull request Dec 27, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add VAT number to User Profile
4 participants