diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/KYCRelatedDataDTO.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/KYCRelatedDataDTO.java index f9011b5e..8432d872 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/KYCRelatedDataDTO.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/KYCRelatedDataDTO.java @@ -2,6 +2,7 @@ package com.gmeremit.online.gmeremittance_native.kycV3.model; import com.gmeremit.online.gmeremittance_native.customwidgets.genderdialog.Gender; import com.gmeremit.online.gmeremittance_native.kycV2.model.kyc.NativeCountry; +import com.gmeremit.online.gmeremittance_native.utils.https.HttpClientV2; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; @@ -204,6 +205,7 @@ public class KYCRelatedDataDTO { return null; } + public IDTextDTO getSelectedGenderFromGenderId(String id) { if (id == null || id.length() < 1) return null; @@ -215,5 +217,33 @@ public class KYCRelatedDataDTO { return null; } + public PersonalInfoDTO getPersonalInfoForKYCSubmission() { + + if (getPersonalInformation() == null) + return null; + return getPersonalInformation().createClone(); + + + } + + public PrimaryInformationDTO getPrimaryInfoForKYCSubmission() { + if (getPrimaryInformation() == null) + return null; + + PrimaryInformationDTO primaryInformationDTO = getPrimaryInformation().createClone(); + if ("8008".equalsIgnoreCase(primaryInformationDTO.getAnotherIDTypeId())) { + primaryInformationDTO.setAnotherIDExpiryDate(""); + } + + return primaryInformationDTO; + } + + + @Override + public String toString() { + String personalInfo = HttpClientV2.getDeserializer().toJson(getPersonalInfoForKYCSubmission()); + String primaryInfo = HttpClientV2.getDeserializer().toJson(getPrimaryInfoForKYCSubmission()); + return "Personal = " + personalInfo + "\nPrimary = " + primaryInfo; + } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PersonalInfoDTO.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PersonalInfoDTO.java index a5a58562..d1e461ff 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PersonalInfoDTO.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PersonalInfoDTO.java @@ -26,6 +26,15 @@ public class PersonalInfoDTO { @Expose private String address; + public PersonalInfoDTO(String fullName, String gender, String dob, String email, String city, String address) { + this.fullName = fullName; + this.gender = gender; + this.dob = dob; + this.email = email; + this.city = city; + this.address = address; + } + public String getFullName() { return fullName; } @@ -100,4 +109,8 @@ public class PersonalInfoDTO { public boolean isCityValid() { return city != null && city.length() > 0; } + + public PersonalInfoDTO createClone() { + return new PersonalInfoDTO(this.fullName,this.gender,this.dob,this.email,this.city,this.address); + } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PrimaryInformationDTO.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PrimaryInformationDTO.java index bded7cb8..853cfe77 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PrimaryInformationDTO.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/model/PrimaryInformationDTO.java @@ -30,6 +30,13 @@ public class PrimaryInformationDTO { @SerializedName("anotherIDNumber") @Expose private String anotherIDNumber; + + @SerializedName("anotherIDIssueDate") + @Expose + private String anotherIDIssueDate; + @SerializedName("anotherIDExpiryDate") + @Expose + private String anotherIDExpiryDate; @SerializedName("branchId") @Expose private String branchId; @@ -37,6 +44,20 @@ public class PrimaryInformationDTO { @Expose private String refferalCode; + public PrimaryInformationDTO(String bankId, String bankAccount, String passportNumber, String passportIssueDate, String passportExpiryDate, String anotherIDTypeId, String anotherIDNumber, String anotherIDIssueDate, String anotherIDExpiryDate, String branchId, String refferalCode) { + this.bankId = bankId; + this.bankAccount = bankAccount; + this.passportNumber = passportNumber; + this.passportIssueDate = passportIssueDate; + this.passportExpiryDate = passportExpiryDate; + AnotherIDTypeId = anotherIDTypeId; + this.anotherIDNumber = anotherIDNumber; + this.anotherIDIssueDate = anotherIDIssueDate; + this.anotherIDExpiryDate = anotherIDExpiryDate; + this.branchId = branchId; + this.refferalCode = refferalCode; + } + public String getBankId() { return bankId; } @@ -93,6 +114,22 @@ public class PrimaryInformationDTO { this.anotherIDNumber = anotherIDNumber; } + public String getAnotherIDIssueDate() { + return anotherIDIssueDate; + } + + public void setAnotherIDIssueDate(String anotherIDIssueDate) { + this.anotherIDIssueDate = anotherIDIssueDate; + } + + public String getAnotherIDExpiryDate() { + return anotherIDExpiryDate; + } + + public void setAnotherIDExpiryDate(String anotherIDExpiryDate) { + this.anotherIDExpiryDate = anotherIDExpiryDate; + } + public String getBranchId() { return branchId; } @@ -130,7 +167,25 @@ public class PrimaryInformationDTO { } + public boolean isAnotherIDIssuedDateValid() { + return anotherIDIssueDate != null && anotherIDIssueDate.length() > 0; + } + + public boolean isAnotherIDExpiryDateValid() { + return anotherIDExpiryDate != null && anotherIDExpiryDate.length() > 0; + } + + + public boolean isAnotherIDTypeValid() { return AnotherIDTypeId != null && AnotherIDTypeId.length() > 0; } + + public boolean isPassportNoValid() { + return passportNumber!=null && passportNumber.length()>0; + } + + public PrimaryInformationDTO createClone() { + return new PrimaryInformationDTO(this.bankId,this.branchId,this.passportNumber,this.passportIssueDate,this.passportExpiryDate,this.AnotherIDTypeId,this.anotherIDNumber,this.anotherIDIssueDate,this.anotherIDExpiryDate,this.branchId,this.refferalCode); + } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3PresenterInterface.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3PresenterInterface.java index 28f1e5d8..1894db6a 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3PresenterInterface.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3PresenterInterface.java @@ -38,6 +38,8 @@ public interface KYCV3PresenterInterface extends BasePresenterInterface { List getAvailableBranchList(); + void sendFullKYCDataUpdate(); + interface KYCV3ViewContractInterface extends BaseContractInterface { diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3ViewModel.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3ViewModel.java index 1f42290a..04429683 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3ViewModel.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/presenter/KYCV3ViewModel.java @@ -1,6 +1,7 @@ package com.gmeremit.online.gmeremittance_native.kycV3.presenter; import android.graphics.Bitmap; +import android.util.Log; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; @@ -181,8 +182,8 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter this.view.getCustomerDetailViewContract().getForm2ViewBindings().getPassportExpiryDateChangeEvent().map(val -> validator.validatePassportExpiryDate(val.toString())), this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIdTypeChangeEvent().map(val -> validator.validateAlternateIdType(val)), this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDNoChangeEvent().map(val -> validator.validateAlternateIdNo(val.toString())), - this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDIssuedDateChangeEvent().map(val -> validator.validateAlternateIdIssuedDate(val.toString())), - this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDExpiryDateChangeEvent().map(val -> validator.validateAlternateIdIssuedDate(val.toString())), + this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDIssuedDateChangeEvent().map(val -> validator.validateAlternateIDIssuedDate(val.toString())), + this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDExpiryDateChangeEvent().map(val -> validator.validateAlternateIDExpiryDate(val.toString())), (isBankValid, isBankAccNoValid, isPassportNumberValid, isPassportIssuedDateValid, isPassportExpiryDateValid, isAlternateIdTypeValid, isAlternateIdValid, isAlternateIssuedDateValid, isAlternateExpiryDateValid) -> { boolean result = isBankValid && isBankAccNoValid && isPassportNumberValid && isPassportIssuedDateValid && isPassportExpiryDateValid && isAlternateIdTypeValid && isAlternateIdValid && isAlternateIssuedDateValid && isAlternateExpiryDateValid; customerDetailForm2Button.setValue(result); @@ -306,6 +307,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter return validator.getKycRelatedDataDTO().getGmeBranchList(); } + @Override + public void sendFullKYCDataUpdate() { + Log.d(TAG, validator.getKycRelatedDataDTO().toString()); + } + public class KycRelatedDataObserver extends GenericApiObserverResponseV2 { @Override @@ -411,10 +417,6 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - private boolean validateAlternateIdIssuedDate(String issuedDate) { - return issuedDate.length() > 0; - } - public boolean validateBank(String bank) { kycRelatedDataDTO.getPrimaryInformation().setBankId(bank); if (kycRelatedDataDTO.getPrimaryInformation().isBankValid()) { @@ -440,11 +442,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter public boolean validatePassportNo(String passportNo) { kycRelatedDataDTO.getPrimaryInformation().setPassportNumber(passportNo); - if (kycRelatedDataDTO.getPrimaryInformation().isBankAccountValid()) { - customerDetailErrorLiveDataDTO.setValueToAccountNoError(null); + if (kycRelatedDataDTO.getPrimaryInformation().isPassportNoValid()) { + customerDetailErrorLiveDataDTO.setValueToPassportNoError(null); return true; } else { - customerDetailErrorLiveDataDTO.setValueToAccountNoError(getStringfromStringId(R.string.empty_field_error_text)); + customerDetailErrorLiveDataDTO.setValueToPassportNoError(getStringfromStringId(R.string.empty_field_error_text)); return false; } @@ -464,7 +466,6 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } public boolean validatePassportExpiryDate(String passportExpiryDate) { - kycRelatedDataDTO.getPrimaryInformation().setPassportExpiryDate(passportExpiryDate); if (kycRelatedDataDTO.getPrimaryInformation().isPassportExpiryDateValid()) { customerDetailErrorLiveDataDTO.setValueToPassportExpiryDateError(null); @@ -486,6 +487,32 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } + + public boolean validateAlternateIDIssuedDate(String alternateIDIssuedDate) { + + kycRelatedDataDTO.getPrimaryInformation().setAnotherIDIssueDate(alternateIDIssuedDate); + if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDIssuedDateValid()) { + customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null); + return true; + } else { + customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(getStringfromStringId(R.string.empty_field_error_text)); + return false; + } + + } + + public boolean validateAlternateIDExpiryDate(String alternateIDIExpiryDate) { + + 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; + } + } + public boolean validatePassportImage(File data) { kycRelatedDataDTO.getPictures().setPassportImageAsFile(data); diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/CustomerDetailFragment.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/CustomerDetailFragment.java index a7b02337..7b7fb7d8 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/CustomerDetailFragment.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/CustomerDetailFragment.java @@ -362,6 +362,9 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present @OnClick(R.id.btn_submit3) public void onClick3() { + + ViewModelProviders.of(getActivity()).get(KYCV3ViewModel.class).sendFullKYCDataUpdate(); + } @@ -511,9 +514,7 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present public void onActivityResult(int requestCode, int resultCode, Intent data) { try { if (requestCode == CAMERA_REQUEST_ALTERNATE_ID || - requestCode == CAMERA_REQUEST_PASSPORT || - requestCode == GALLERY_REQUEST_PASSPORT || - requestCode == GALLERY_REQUEST_ALTERNATE_ID + requestCode == CAMERA_REQUEST_PASSPORT ) { if (resultCode == RESULT_OK) { @@ -550,7 +551,7 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present this.currentRequest = currentRequest; CropImage.activity(photoURI) .setCropMenuCropButtonTitle(getString(R.string.done_text)) - .start(getActivity(), this); + .start(getContext(), this); } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/viewdto/CustomerDetailErrorLiveDataDTO.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/viewdto/CustomerDetailErrorLiveDataDTO.java index 358063ff..38a1f715 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/viewdto/CustomerDetailErrorLiveDataDTO.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV3/view/personal/viewdto/CustomerDetailErrorLiveDataDTO.java @@ -20,6 +20,8 @@ public class CustomerDetailErrorLiveDataDTO { private MutableLiveData passportExpiryDateError; private MutableLiveData anotherIdTypeError; private MutableLiveData anotherIdNumberError; + private MutableLiveData anotherIdIssuedDateError; + private MutableLiveData anotherIdExpiryDateError; private MutableLiveData branchError; private MutableLiveData referralCodeError; @@ -41,6 +43,8 @@ public class CustomerDetailErrorLiveDataDTO { passportExpiryDateError=new MutableLiveData<>(); anotherIdTypeError=new MutableLiveData<>(); anotherIdNumberError=new MutableLiveData<>(); + anotherIdExpiryDateError=new MutableLiveData<>(); + anotherIdIssuedDateError=new MutableLiveData<>(); branchError=new MutableLiveData<>(); referralCodeError=new MutableLiveData<>(); } @@ -108,6 +112,16 @@ public class CustomerDetailErrorLiveDataDTO { { anotherIdNumberError.setValue(error); } + + public void setValueToAnotherIDIssuedDateError(String error) + { + anotherIdIssuedDateError.setValue(error); + } + public void setValueToAnotherIDExpiryDateError(String error) + { + anotherIdExpiryDateError.setValue(error); + } + public void setValueToBranchError(String error) { branchError.setValue(error);