Browse Source

Alternate Id validation fixes

master
Preyea Regmi 5 years ago
parent
commit
3634aed077
  1. 79
      app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3ViewModel.java
  2. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/CustomerDetailFragment.java
  3. 1
      app/src/main/res/layout/fragment_kyc_customer_detail.xml

79
app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3ViewModel.java

@ -35,7 +35,6 @@ import java.util.List;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subjects.BehaviorSubject;
@ -45,7 +44,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 static final int ID_CARD_VALID_LENGTH = 14;
private final KYCV3PresenterInterface.KYCV3ViewContractInterface view;
private final KYCV3GatewayInterface gateway;
private final CompositeDisposable customerDetailViewSubscriptions;
@ -57,7 +56,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter
private MutableLiveData<Boolean> customerDetailForm1Button;
private MutableLiveData<Boolean> customerDetailForm2Button;
private MutableLiveData<Boolean> customerDetailForm3Button;
private MutableLiveData<Boolean> customerDetailAlternateIDFieldEnableLiveData;
private MutableLiveData<Boolean> alternateIDNumberFieldEnableLiveData;
private MutableLiveData<Bitmap> passportImageLiveData;
private MutableLiveData<Bitmap> alternateIDImageLiveData;
private MutableLiveData<Boolean> alternateIDIssueVisibilityDateRequireLiveData;
@ -109,7 +108,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter
this.customerDetailForm2Button = new MutableLiveData<>();
this.customerDetailForm3Button = new MutableLiveData<>();
this.alternateIdRelatedViewResetLiveData = new MutableLiveData<>();
this.customerDetailAlternateIDFieldEnableLiveData = new MutableLiveData<>();
this.alternateIDNumberFieldEnableLiveData = new MutableLiveData<>();
this.passportImageLiveData = new MutableLiveData<>();
this.alternateIDImageLiveData = new MutableLiveData<>();
this.alternateIDIssueVisibilityDateRequireLiveData = new MutableLiveData<>();
@ -270,24 +269,23 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter
}
private Observable<Boolean> setupAlternateIDDependenciesValidation() {
return Observable.combineLatest(
this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDNoChangeEvent().map(val -> {
log("Alternated Id No started emission" + val);
return Observable.merge(this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDNoChangeEvent().map(val -> {
log("Alternated Id No started emission: " + val);
return validator.validateAlternateIdNo2(val.toString());
}),
this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDIssuedDateChangeEvent().map(val -> {
log("Alternated Id Issued Date started emission" + val);
log("Alternated Id Issued Date started emission:" + val);
return validator.validateAlternateIDIssuedDate2(val.toString());
}),
this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDExpiryDateChangeEvent().map(val -> {
log("Alternated Id Expiry Date started emission" + val);
log("Alternated Id Expiry Date started emission:" + val);
return validator.validateAlternateIDExpiryDate2(val.toString());
}),
this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIdTypeChangeEvent().map(val -> {
log("Alternated Id Type started emission" + val.getText());
log("Alternated Id Type started emission:" + val.getText());
return validator.validateAlternateIdType2(val);
}),
(isAlternateIdNoValid, isAlternateIdIssuedDateValid, isAlternatedIDExpiryDateValid,isAlternateIdTypeValid) -> isAlternateIdNoValid && isAlternateIdIssuedDateValid && isAlternatedIDExpiryDateValid&&isAlternateIdTypeValid);
})
);
}
private Observable<Boolean> setupAlternateIDDependenciesValidation2() {
@ -362,7 +360,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter
//Update View
alternateIDIssueVisibilityDateRequireLiveData.setValue(false);
alternateIDExpiryDateVisibilityLiveData.setValue(false);
customerDetailAlternateIDFieldEnableLiveData.setValue(false);
alternateIDNumberFieldEnableLiveData.setValue(false);
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(null);
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null);
@ -439,7 +437,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter
@Override
public LiveData<Boolean> getForm2AlternateIdNumberFieldAccessLiveData() {
return customerDetailAlternateIDFieldEnableLiveData;
return alternateIDNumberFieldEnableLiveData;
}
@Override
@ -859,76 +857,83 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter
customerDetailErrorLiveDataDTO.setValueToAnotherIdTypeError("Select different ID Type");
}
}
customerDetailAlternateIDFieldEnableLiveData.setValue(result);
alternateIDNumberFieldEnableLiveData.setValue(result);
log("Alternate Id Type validation result: " + result);
return result;
}
private boolean validateAlternateIDRelatedFieldData() {
boolean result = true;
if (kycRelatedDataDTO.getPrimaryInformation() != null) {
String selectedIdType = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType();
String selectedIdType = "";
String selectedIdTypeId = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType();
String alternateIdExpiryDate = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDExpiryDate();
String alternateIdIssuedDate = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDIssueDate();
String alternateIdNumber = kycRelatedDataDTO.getPrimaryInformation().getAnotherIDNumber();
if (selectedIdType == null || selectedIdType.length() == 0)
if (selectedIdTypeId == null || selectedIdTypeId.length() == 0)
return true;
else
selectedIdType = kycRelatedDataDTO.getSelectedIdTYpeFromId(selectedIdTypeId).getText();
if (ID_TYPE_NATIONAL_ID_CARD.equalsIgnoreCase(selectedIdType)) {
boolean nationalIDCardValidationResult = true;
if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0)
nationalIDCardValidationResult = false;
result = false;
else {
if (alternateIdNumber == null || alternateIdNumber.length() != ID_CARD_VALID_LENGTH) {
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid National Id Card");
nationalIDCardValidationResult = false;
result = false;
}
}
return nationalIDCardValidationResult;
log(selectedIdType + " result: " + result);
} else if (ID_TYPE_ALIEN_REGISTRATION_CARD.equalsIgnoreCase(selectedIdType)) {
boolean alienCardValidationResult = true;
if (alternateIdExpiryDate == null || alternateIdExpiryDate.length() == 0)
alienCardValidationResult = false;
result = false;
else if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0)
alienCardValidationResult = false;
result = false;
else {
if (alternateIdNumber == null || alternateIdNumber.length() != ID_CARD_VALID_LENGTH) {
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid Alien Id Card");
alienCardValidationResult = false;
result = false;
}
}
return alienCardValidationResult;
log(selectedIdType + " result: " + result);
} else if (ID_TYPE_DRIVING_LICENSE.equalsIgnoreCase(selectedIdType)) {
boolean drivingValidationResult = true;
if (alternateIdExpiryDate == null || alternateIdExpiryDate.length() == 0)
drivingValidationResult = false;
result = false;
else if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0)
drivingValidationResult = false;
result = false;
else {
if (alternateIdNumber == null || alternateIdNumber.length() != ID_CARD_VALID_LENGTH) {
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid Driving License Card");
drivingValidationResult = false;
result = false;
}
}
return drivingValidationResult;
log(selectedIdType + " result: " + result);
} else if (ID_TYPE_PASSPORT.equalsIgnoreCase(selectedIdType)) {
boolean passportValidationResult = true;
if (alternateIdExpiryDate == null || alternateIdExpiryDate.length() == 0)
passportValidationResult = false;
result = false;
else if (alternateIdIssuedDate == null || alternateIdIssuedDate.length() == 0)
passportValidationResult = false;
result = false;
else {
if (alternateIdNumber == null || alternateIdNumber.length() < 1) {
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError("Invalid Passport");
passportValidationResult = false;
result = false;
}
}
return passportValidationResult;
log(selectedIdType + " result: " + result);
}
else
{
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(null);
result=false;
}
return result;
}
log("Alternated Id Dependencies result : " + true);
return true;
}
@ -966,7 +971,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter
customerDetailErrorLiveDataDTO.setValueToAnotherIdTypeError("Select different ID Type");
}
}
customerDetailAlternateIDFieldEnableLiveData.setValue(result);
alternateIDNumberFieldEnableLiveData.setValue(result);
log("Alternate Id Type validation result: " + result);
return result;
}

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/CustomerDetailFragment.java

@ -278,7 +278,7 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present
kycv3ViewModel.getForm1SubmissionReadyLiveData().observe(getViewLifecycleOwner(), val -> btnSubmit1.setEnabled(val));
kycv3ViewModel.getForm2SubmissionReadyLiveData().observe(getViewLifecycleOwner(), val -> btnSubmit2.setEnabled(val));
kycv3ViewModel.getForm3SubmissionReadyLiveData().observe(getViewLifecycleOwner(), val -> btnSubmit3.setEnabled(val));
kycv3ViewModel.getForm2AlternateIdNumberFieldAccessLiveData().observe(getViewLifecycleOwner(), val -> ed_anotherId.setEnabled(val));
// kycv3ViewModel.getForm2AlternateIdNumberFieldAccessLiveData().observe(getViewLifecycleOwner(), val -> ed_anotherId.setEnabled(val));
}
private void subscribeToCustomerRelatedData(KYCV3ViewModel kycv3ViewModel) {
@ -1214,7 +1214,7 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present
}
public Observable<CharSequence> getAlternateIDNoChangeEvent() {
return RxTextView.textChanges(ed_anotherId).skipInitialValue().filter(val -> val != null);
return RxTextView.textChanges(ed_anotherId).skipInitialValue();
}

1
app/src/main/res/layout/fragment_kyc_customer_detail.xml

@ -543,7 +543,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:enabled="false"
android:inputType="textMultiLine|textNoSuggestions" />
</com.gmeremit.online.gmeremittance_native.customwidgets.GMETextInputLayout>

Loading…
Cancel
Save