diff --git a/packages/account/src/Configs/employment-tax-info-config.ts b/packages/account/src/Configs/employment-tax-info-config.ts index 71b025fb3dad..971632c02898 100644 --- a/packages/account/src/Configs/employment-tax-info-config.ts +++ b/packages/account/src/Configs/employment-tax-info-config.ts @@ -36,7 +36,7 @@ const generateEmploymentTaxInfoFormValues = ({ }, }); -const getEmploymentTaxIfoConfig = ( +const getEmploymentTaxInfoConfig = ( { account_settings, residence_list, @@ -60,4 +60,4 @@ const getEmploymentTaxIfoConfig = ( }; }; -export default getEmploymentTaxIfoConfig; +export default getEmploymentTaxInfoConfig; diff --git a/packages/account/src/Configs/user-profile-validation-config.ts b/packages/account/src/Configs/user-profile-validation-config.ts index 6e2fdb1a70f7..e16773fc3ac4 100644 --- a/packages/account/src/Configs/user-profile-validation-config.ts +++ b/packages/account/src/Configs/user-profile-validation-config.ts @@ -2,7 +2,6 @@ import { localize } from '@deriv-com/translations'; import * as Yup from 'yup'; import { ValidationConstants } from '@deriv-com/utils'; import dayjs from 'dayjs'; -import { TinValidations } from '@deriv/api/types'; import { TEmployeeDetailsTinValidationConfig } from '../Types'; const { @@ -25,6 +24,7 @@ type TINDepdendents = { * This flag indicates that tin was skipped before and was set by BE */ is_tin_auto_set?: boolean; + is_employment_status_tin_mandatory?: boolean; }; Yup.addMethod(Yup.string, 'validatePhoneNumberLength', function (message) { @@ -38,10 +38,20 @@ Yup.addMethod(Yup.string, 'validatePhoneNumberLength', function (message) { }); }); -const makeTinOptional = ({ is_mf, is_real, tin_skipped, is_tin_auto_set }: TINDepdendents) => { +const makeTinOptional = ({ + is_mf, + is_real, + tin_skipped, + is_tin_auto_set, + is_employment_status_tin_mandatory, +}: TINDepdendents) => { const check_if_tin_skipped = tin_skipped && !is_tin_auto_set; if (is_real) { - return check_if_tin_skipped; + // Students and unemployed are not required to provide TIN to have a regulated MT5 jurisdiction + if (is_tin_auto_set && is_employment_status_tin_mandatory) { + return true; + } + return check_if_tin_skipped || !is_employment_status_tin_mandatory; } // Check For Virtual account if (is_mf) { @@ -56,9 +66,14 @@ export const getEmploymentAndTaxValidationSchema = ({ is_real = false, is_tin_auto_set = false, is_duplicate_account = false, + is_employment_status_tin_mandatory = false, }: TEmployeeDetailsTinValidationConfig) => { return Yup.object({ - employment_status: Yup.string().required(localize('Employment status is required.')), + employment_status: Yup.string().when('is_employment_status_tin_mandatory', { + is: () => is_employment_status_tin_mandatory, + then: Yup.string().required(localize('Employment status is required.')), + otherwise: Yup.string().notRequired(), + }), tax_residence: Yup.string().when('is_mf', { is: () => is_mf, then: Yup.string().required(localize('Tax residence is required.')), @@ -73,7 +88,14 @@ export const getEmploymentAndTaxValidationSchema = ({ }), tax_identification_number: Yup.string() .when(['tin_skipped'], { - is: (tin_skipped: boolean) => makeTinOptional({ is_mf, is_real, tin_skipped, is_tin_auto_set }), + is: (tin_skipped: boolean) => + makeTinOptional({ + is_mf, + is_real, + tin_skipped, + is_tin_auto_set, + is_employment_status_tin_mandatory, + }), then: Yup.string().notRequired(), otherwise: Yup.string().required(localize('Tax identification number is required.')), }) diff --git a/packages/account/src/Containers/employment-tax-details-container/employment-tax-details-container.tsx b/packages/account/src/Containers/employment-tax-details-container/employment-tax-details-container.tsx index ad06305ab640..ff53accab6bf 100644 --- a/packages/account/src/Containers/employment-tax-details-container/employment-tax-details-container.tsx +++ b/packages/account/src/Containers/employment-tax-details-container/employment-tax-details-container.tsx @@ -39,11 +39,19 @@ const EmploymentTaxDetailsContainer = observer( const { data: residence_list } = useResidenceList(); const { client } = useStore(); - const { is_virtual, account_settings } = client; + const { is_virtual, account_settings, account_status } = client; const { tin_employment_status_bypass } = tin_validation_config; - const is_tin_required = !is_virtual && !tin_employment_status_bypass?.includes(values.employment_status); + const is_employment_status_mandatory = is_virtual + ? true + : Boolean(account_status?.status?.includes('mt5_additional_kyc_required')); + + const is_tin_required = + !is_virtual && + values.employment_status && + !tin_employment_status_bypass?.includes(values.employment_status) && + is_employment_status_mandatory; const [is_tax_residence_popover_open, setIsTaxResidencePopoverOpen] = useState(false); const [is_tin_popover_open, setIsTinPopoverOpen] = useState(false); @@ -132,15 +140,11 @@ const EmploymentTaxDetailsContainer = observer( const isFieldDisabled = (field_name: string) => isFieldImmutable(field_name, editable_fields); - // [TODO] - This should come from BE - const should_disable_employment_status = - isFieldDisabled('employment_status') || Boolean(is_virtual && client.account_settings.employment_status); - return (