Skip to content

Commit

Permalink
feat: add vat number
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 committed Sep 21, 2023
1 parent eef62a2 commit 07a0af1
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 4 deletions.
3 changes: 3 additions & 0 deletions authentication/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ class RegisterExtraDetailsSerializer(SocialAuthSerializer):
company = serializers.CharField(write_only=True)
job_title = serializers.CharField(write_only=True)
industry = serializers.CharField(write_only=True, allow_blank=True, required=False)
vat_number = serializers.CharField(
write_only=True, allow_blank=True, required=False
)
job_function = serializers.CharField(
write_only=True, allow_blank=True, required=False
)
Expand Down
1 change: 1 addition & 0 deletions ecommerce/mail_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def send_ecommerce_order_receipt(order, cyber_source_provided_email=None):
"city": purchaser.get("city"),
"country": country.name if country else None,
"company": purchaser.get("company"),
"vat_number": purchaser.get("vat_number"),
},
},
),
Expand Down
1 change: 1 addition & 0 deletions mail/templates/product_order_receipt/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <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>
<strong style="font-weight: 700;">VAT Number:</strong> {{ purchaser.vat_number }}<br>
</p>
{% if receipt or coupon %}
<h3 style="color: #000000; font-size: 16px; font-weight: 700; line-height: 18px; margin: 0 0 20px;">Payment Information</h3>
Expand Down
13 changes: 13 additions & 0 deletions static/js/components/forms/ProfileFormFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,18 @@ export const ProfileFields = () => (
</div>
</div>
</div>
<div className="form-group">
<div className="row">
<div className="col">
<label htmlFor="profile.vat_number" className="font-weight-bold">
VAT Number
</label>
<Field type="text" name="profile.vat_number" className="form-control" />
<ErrorMessage name="profile.vat_number" component={FormError} />
</div>
<div className="col">
</div>
</div>
</div>
</React.Fragment>
)
6 changes: 6 additions & 0 deletions static/js/containers/pages/ReceiptPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ export class ReceiptPage extends React.Component<Props> {
{orderReceipt.purchaser.email}
</dd>
</dl>
<dl>
<dt>VAT Number:</dt>
<dd id="purchaserVATNumber">
{orderReceipt.purchaser.vat_number}
</dd>
</dl>
</div>
<h3>Payment Information</h3>
{orderReceipt.receipt ? (
Expand Down
6 changes: 6 additions & 0 deletions static/js/containers/pages/profile/ViewProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ export class ViewProfilePage extends React.Component<Props> {
{currentUser.profile.highest_education}
</div>
</div>
<div className="row">
<div className="col">VAT Number</div>
<div className="col">
{currentUser.profile.vat_number}
</div>
</div>
</div>
) : (
<div className="col-12 auth-form">
Expand Down
3 changes: 2 additions & 1 deletion static/js/factories/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const makeUser = (username: ?string): LoggedInUser => ({
job_function: "",
leadership_level: "",
years_experience: 20,
highest_education: "Doctorate"
highest_education: "Doctorate",
vat_number: "PL1011000",
},
legal_address: {
street_address: [casual.street],
Expand Down
6 changes: 4 additions & 2 deletions static/js/flow/authTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export type LegalAddress = {
country: string,
state_or_territory?: string,
postal_code?: string,
company?: string
company?: string,
vat_number?: string,
}

export type ExtendedLegalAddress = LegalAddress & {
Expand All @@ -72,7 +73,8 @@ export type Profile = {
years_experience: ?number,
company_size: ?number,
leadership_level: ?string,
highest_education: ?string
highest_education: ?string,
vat_number: ?string,
}

export type User = {
Expand Down
18 changes: 18 additions & 0 deletions users/migrations/0015_profile_vat_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.21 on 2023-09-20 12:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("users", "0014_alter_user_name"),
]

operations = [
migrations.AddField(
model_name="profile",
name="vat_number",
field=models.CharField(blank=True, max_length=255, null=True),
),
]
1 change: 1 addition & 0 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class Profile(TimestampedModel):
highest_education = models.CharField(
max_length=60, blank=True, default="", choices=HIGHEST_EDUCATION_CHOICES
)
vat_number = models.CharField(max_length=255, blank=True, null=True)

@property
def is_complete(self):
Expand Down
9 changes: 8 additions & 1 deletion users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class ExtendedLegalAddressSerializer(LegalAddressSerializer):

email = serializers.SerializerMethodField()
company = serializers.SerializerMethodField()
vat_number = serializers.SerializerMethodField()

def get_email(self, instance):
"""Get email from the linked user object"""
Expand All @@ -170,9 +171,13 @@ def get_company(self, instance):
"""Get company from the linked user object"""
return instance.user.profile.company

def get_vat_number(self, instance):
"""Get vat_number from the linked user object"""
return instance.user.profile.vat_number

class Meta:
model = LegalAddress
fields = LegalAddressSerializer.Meta.fields + ("email", "company")
fields = LegalAddressSerializer.Meta.fields + ("email", "company", "vat_number")
extra_kwargs = LegalAddressSerializer.Meta.extra_kwargs


Expand All @@ -193,6 +198,7 @@ class Meta:
"years_experience",
"leadership_level",
"highest_education",
"vat_number",
"created_on",
"updated_on",
)
Expand Down Expand Up @@ -221,6 +227,7 @@ class Meta:
"years_experience",
"leadership_level",
"highest_education",
"vat_number",
)


Expand Down
1 change: 1 addition & 0 deletions users/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def test_get_user_by_me(mocker, client, user, is_anonymous, show_enrollment_code
"years_experience": user.profile.years_experience,
"highest_education": user.profile.highest_education,
"industry": user.profile.industry,
"vat_number": user.profile.vat_number,
},
"unused_coupons": patched_unused_coupon_api.return_value,
"is_anonymous": False,
Expand Down

0 comments on commit 07a0af1

Please sign in to comment.