|
|
@ -45,6 +45,7 @@ import static android.app.Activity.RESULT_OK; |
|
|
|
public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInterface { |
|
|
|
|
|
|
|
|
|
|
|
private static final int ID_CARD_VALID_LENGTH = 13; |
|
|
|
private final KYCV3PresenterInterface.KYCV3ViewContractInterface view; |
|
|
|
private final KYCV3GatewayInterface gateway; |
|
|
|
private final CompositeDisposable customerDetailViewSubscriptions; |
|
|
@ -282,35 +283,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
log("Alternated Id Expiry Date started emission" + val); |
|
|
|
return validator.validateAlternateIDExpiryDate2(val.toString()); |
|
|
|
}), |
|
|
|
(isAlternateIdNoValid, isAlternateIdIssuedDateValid, isAlternatedIDExpiryDateValid) -> isAlternateIdNoValid && isAlternateIdIssuedDateValid && isAlternatedIDExpiryDateValid |
|
|
|
).withLatestFrom(this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIdTypeChangeEvent().map(val -> { |
|
|
|
this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIdTypeChangeEvent().map(val -> { |
|
|
|
log("Alternated Id Type started emission" + val.getText()); |
|
|
|
|
|
|
|
alternateIdRelatedViewResetLiveData.setValue(true); |
|
|
|
|
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(null); |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null); |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDExpiryDateError(null); |
|
|
|
|
|
|
|
//Update Data |
|
|
|
if (validator.getKycRelatedDataDTO().getPrimaryInformation() != null) { |
|
|
|
validator.getKycRelatedDataDTO().getPrimaryInformation().setAnotherIDNumber(""); |
|
|
|
validator.getKycRelatedDataDTO().getPrimaryInformation().setAnotherIDIssueDate(""); |
|
|
|
validator.getKycRelatedDataDTO().getPrimaryInformation().setAnotherIDExpiryDate(""); |
|
|
|
} |
|
|
|
|
|
|
|
alternateIdRelatedValidationSubject.onNext(false); |
|
|
|
|
|
|
|
return validator.validateAlternateIdType(val); |
|
|
|
return validator.validateAlternateIdType2(val); |
|
|
|
}), |
|
|
|
(isAlternatedTypeDependenciesValid, isAlternateIdTypeValid) -> { |
|
|
|
log("AlternatedIDDependencies isValid : " + isAlternatedTypeDependenciesValid); |
|
|
|
log("AlternateIDType isValid : " + isAlternateIdTypeValid); |
|
|
|
return isAlternatedTypeDependenciesValid && isAlternateIdTypeValid; |
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
(isAlternateIdNoValid, isAlternateIdIssuedDateValid, isAlternatedIDExpiryDateValid,isAlternateIdTypeValid) -> isAlternateIdNoValid && isAlternateIdIssuedDateValid && isAlternatedIDExpiryDateValid&&isAlternateIdTypeValid); |
|
|
|
} |
|
|
|
|
|
|
|
private Observable<Boolean> setupAlternateIDDependenciesValidation2() { |
|
|
@ -850,7 +827,6 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
|
|
|
|
public boolean validateAlternateIdType2(IDTypeDTO val) { |
|
|
|
|
|
|
|
boolean result = false; |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation() == null) |
|
|
|
kycRelatedDataDTO.setPrimaryInformation(new PrimaryInformationDTO()); |
|
|
@ -858,9 +834,6 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
if (val == null) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdTypeError("Select different ID Type"); |
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDType(""); |
|
|
|
kycRelatedDataDTO.logFormSubmissionData(); |
|
|
|
} else if (val.getId() == null || val.getId().length() == 0) { |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDType(val.getId()); |
|
|
|
anotherIdPictureLabeliveData.setValue(getAnotherIdTranslatedLable(val.getText())); |
|
|
@ -870,39 +843,95 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
view.getCustomerDetailViewContract().updateAnotherIdNumberMask(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDTypeValid()) { |
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(false); |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(false); |
|
|
|
boolean hasIssuedDateRequiredField = false; |
|
|
|
boolean hasExpiryDateRequiredField = false; |
|
|
|
for (String dependent : val.getDependent()) { |
|
|
|
if ("docIssueDate".equalsIgnoreCase(dependent)) { |
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(true); |
|
|
|
hasIssuedDateRequiredField = true; |
|
|
|
|
|
|
|
} else if ("docExpiryDate".equalsIgnoreCase(dependent)) { |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(true); |
|
|
|
hasExpiryDateRequiredField = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!hasExpiryDateRequiredField) |
|
|
|
anotherIdExpDateLiveData.setValue("Asf"); |
|
|
|
else |
|
|
|
anotherIdExpDateLiveData.setValue(""); |
|
|
|
|
|
|
|
if (!hasIssuedDateRequiredField) |
|
|
|
anotherIdIssuedDateLiveData.setValue("asf"); |
|
|
|
else |
|
|
|
anotherIdIssuedDateLiveData.setValue(""); |
|
|
|
result = true; |
|
|
|
result = validateAlternateIDRelatedFieldData(); |
|
|
|
} else { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdTypeError("Select different ID Type"); |
|
|
|
} |
|
|
|
} |
|
|
|
customerDetailAlternateIDFieldEnableLiveData.setValue(result); |
|
|
|
log("Alternate Id Type validation result: " + result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean validateAlternateIDRelatedFieldData() { |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation() != null) { |
|
|
|
String selectedIdType = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType(); |
|
|
|
String alternateIdExpiryDate = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDExpiryDate(); |
|
|
|
String alternateIdIssuedDate = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDIssueDate(); |
|
|
|
String alternateIdNumber = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDNumber(); |
|
|
|
|
|
|
|
if (selectedIdType == null || selectedIdType.length() == 0) |
|
|
|
return true; |
|
|
|
|
|
|
|
if (ID_TYPE_NATIONAL_ID_CARD.equalsIgnoreCase(selectedIdType)) { |
|
|
|
boolean nationalIDCardValidationResult = true; |
|
|
|
|
|
|
|
if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0) |
|
|
|
nationalIDCardValidationResult = false; |
|
|
|
else { |
|
|
|
if (alternateIdNumber == null || alternateIdNumber.length() != ID_CARD_VALID_LENGTH) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid National Id Card"); |
|
|
|
nationalIDCardValidationResult = false; |
|
|
|
} |
|
|
|
} |
|
|
|
return nationalIDCardValidationResult; |
|
|
|
} else if (ID_TYPE_ALIEN_REGISTRATION_CARD.equalsIgnoreCase(selectedIdType)) { |
|
|
|
boolean alienCardValidationResult = true; |
|
|
|
|
|
|
|
if (alternateIdExpiryDate == null || alternateIdExpiryDate.length() == 0) |
|
|
|
alienCardValidationResult = false; |
|
|
|
else if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0) |
|
|
|
alienCardValidationResult = false; |
|
|
|
else { |
|
|
|
if (alternateIdNumber == null || alternateIdNumber.length() != ID_CARD_VALID_LENGTH) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid Alien Id Card"); |
|
|
|
alienCardValidationResult = false; |
|
|
|
} |
|
|
|
} |
|
|
|
return alienCardValidationResult; |
|
|
|
} else if (ID_TYPE_DRIVING_LICENSE.equalsIgnoreCase(selectedIdType)) { |
|
|
|
boolean drivingValidationResult = true; |
|
|
|
if (alternateIdExpiryDate == null || alternateIdExpiryDate.length() == 0) |
|
|
|
drivingValidationResult = false; |
|
|
|
else if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0) |
|
|
|
drivingValidationResult = false; |
|
|
|
else { |
|
|
|
if (alternateIdNumber == null || alternateIdNumber.length() != ID_CARD_VALID_LENGTH) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid Driving License Card"); |
|
|
|
drivingValidationResult = false; |
|
|
|
} |
|
|
|
} |
|
|
|
return drivingValidationResult; |
|
|
|
} else if (ID_TYPE_PASSPORT.equalsIgnoreCase(selectedIdType)) { |
|
|
|
boolean passportValidationResult = true; |
|
|
|
if (alternateIdExpiryDate == null || alternateIdExpiryDate.length() == 0) |
|
|
|
passportValidationResult = false; |
|
|
|
else if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0) |
|
|
|
passportValidationResult = false; |
|
|
|
else { |
|
|
|
if (alternateIdNumber == null || alternateIdNumber.length() < 1) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid Passport"); |
|
|
|
passportValidationResult = false; |
|
|
|
} |
|
|
|
} |
|
|
|
return passportValidationResult; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean validateAlternateIdType(IDTypeDTO val) { |
|
|
|
boolean result = false; |
|
|
@ -921,6 +950,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
view.getCustomerDetailViewContract().updateAnotherIdNumberMask(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDTypeValid()) { |
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(false); |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(false); |
|
|
@ -1004,7 +1034,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDNoValid()) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(null); |
|
|
|
view.getCustomerDetailViewContract().enableAlternateIdFocusChangeAndImeOptionListener(true); |
|
|
|
return true; |
|
|
|
return validateAlternateIDRelatedFieldData(); |
|
|
|
} else { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(getStringfromStringId(R.string.empty_field_error_text)); |
|
|
|
view.getCustomerDetailViewContract().enableAlternateIdFocusChangeAndImeOptionListener(false); |
|
|
@ -1020,15 +1050,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
kycRelatedDataDTO.setPrimaryInformation(new PrimaryInformationDTO()); |
|
|
|
|
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDIssueDate(alternateIDIssuedDate); |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDIssuedDateValid()) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null); |
|
|
|
Log.d("AlternateIdValidation", "Issued Date : " + "Valid"); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(getStringfromStringId(R.string.empty_field_error_text)); |
|
|
|
Log.d("AlternateIdValidation", "Issued Date : " + "InValid"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return validateAlternateIDRelatedFieldData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -1042,13 +1064,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDExpiryDate(alternateIDIExpiryDate); |
|
|
|
|
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDExpiryDateValid()) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDExpiryDateError(null); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDExpiryDateError(getStringfromStringId(R.string.empty_field_error_text)); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return validateAlternateIDRelatedFieldData(); |
|
|
|
} |
|
|
|
|
|
|
|
public boolean validatePassportImage(File data) { |
|
|
|