From d7e7dad3b090b9545a32b6c12ce7be580a7bbd4a Mon Sep 17 00:00:00 2001 From: Santosh Bhandary Date: Thu, 10 Sep 2020 14:09:05 +0545 Subject: [PATCH] Occupation post and get added in Existing Kyc Screen --- .../gateway/ExistingExistingKYCV3Gateway.java | 3 ++ .../model/ExistingKYCRelatedDataDTO.java | 22 +++++++++++ .../model/ExistingPersonalInfoDTO.java | 19 +++++++++ .../ExistingKYCV3PresenterInterface.java | 1 + .../presenter/ExistingKYCV3ViewModel.java | 22 ++++++++++- .../ExistingCustomerDetailFragment.java | 39 ++++++++++++++++++- .../ExistingCustomerDetailViewLiveData.java | 17 ++++++++ .../kyc/newCustomer/gateway/KYCV3Gateway.java | 1 - .../fragment_existing_kyc_customer_detail.xml | 14 +++++++ app/src/main/res/values/strings.xml | 3 ++ 10 files changed, 138 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/gateway/ExistingExistingKYCV3Gateway.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/gateway/ExistingExistingKYCV3Gateway.java index 98dd4e39..88003635 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/gateway/ExistingExistingKYCV3Gateway.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/gateway/ExistingExistingKYCV3Gateway.java @@ -62,6 +62,7 @@ public class ExistingExistingKYCV3Gateway extends PrivilegedGateway implements E if (existingPersonalInfoDTO != null) { map.put("employeerName", createStringUploadValue(existingPersonalInfoDTO.getEmployeerName())); + map.put("occupation", createStringUploadValue(existingPersonalInfoDTO.getOccupation())); map.put("sourceOfFund", createStringUploadValue(existingPersonalInfoDTO.getSourceOfFund())); map.put("monthlyIncome", createStringUploadValue(existingPersonalInfoDTO.getMonthlyIncome())); map.put("businessType", createStringUploadValue(existingPersonalInfoDTO.getBusinessType())); @@ -131,6 +132,7 @@ public class ExistingExistingKYCV3Gateway extends PrivilegedGateway implements E existingKycRelatedDataDTO.setBusniessType(mockedDAta); existingKycRelatedDataDTO.setIdType(mockedDAta); + existingKycRelatedDataDTO.setOccupationList(mockedDAta); existingKycRelatedDataDTO.setSourceOfFund(mockedDAta); existingKycRelatedDataDTO.setMonthlyIncome(mockedDAta); existingKycRelatedDataDTO.setVisaStatusList(mockedDAta); @@ -140,6 +142,7 @@ public class ExistingExistingKYCV3Gateway extends PrivilegedGateway implements E "1", "John Doe", "2", + "2", "3", "123134123", "asdf@asd.com", diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingKYCRelatedDataDTO.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingKYCRelatedDataDTO.java index bdb35084..ab317b2e 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingKYCRelatedDataDTO.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingKYCRelatedDataDTO.java @@ -9,6 +9,9 @@ public class ExistingKYCRelatedDataDTO { @SerializedName("MonthlyIncome") @Expose private List monthlyIncome = null; + @SerializedName("OccupationList") + @Expose + private List occupationList = null; @SerializedName("SourceOfFund") @Expose private List sourceOfFund = null; @@ -42,6 +45,14 @@ public class ExistingKYCRelatedDataDTO { this.monthlyIncome = monthlyIncome; } + public List getOccupationList() { + return occupationList; + } + + public void setOccupationList(List occupationList) { + this.occupationList = occupationList; + } + public List getSourceOfFund() { return sourceOfFund; } @@ -50,6 +61,7 @@ public class ExistingKYCRelatedDataDTO { this.sourceOfFund = sourceOfFund; } + public List getBusniessType() { return busniessType; } @@ -136,6 +148,16 @@ public class ExistingKYCRelatedDataDTO { + public ExistingIDTextDTO getOccupationFromId(String id) { + if (id == null || id.length() < 1) + return null; + for (ExistingIDTextDTO item : occupationList) { + if (id.equalsIgnoreCase(item.getId())) + return item; + } + return null; + } + public ExistingIDTextDTO getSourceOfFundFromId(String id) { if (id == null || id.length() < 1) return null; diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingPersonalInfoDTO.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingPersonalInfoDTO.java index d894409f..67b8dcd0 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingPersonalInfoDTO.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/model/ExistingPersonalInfoDTO.java @@ -14,6 +14,10 @@ public class ExistingPersonalInfoDTO { @Expose private String employeerName; + @SerializedName("occupation") + @Expose + private String occupation; + @SerializedName("sourceOfFund") @Expose private String sourceOfFund; @@ -48,6 +52,7 @@ public class ExistingPersonalInfoDTO { public ExistingPersonalInfoDTO( String visaStatus, String employeerName, + String occupation, String sourceOfFund, String monthlyIncome, String mobile, @@ -58,6 +63,7 @@ public class ExistingPersonalInfoDTO { String businessType) { this.visaStatus = visaStatus; this.employeerName = employeerName; + this.occupation = occupation; this.sourceOfFund = sourceOfFund; this.monthlyIncome = monthlyIncome; this.mobile = mobile; @@ -68,6 +74,14 @@ public class ExistingPersonalInfoDTO { this.businessType=businessType; } + public String getOccupation() { + return occupation; + } + + public void setOccupation(String occupation) { + this.occupation = occupation; + } + public String getEmployeerName() { return employeerName; } @@ -177,6 +191,7 @@ public class ExistingPersonalInfoDTO { return new ExistingPersonalInfoDTO( this.visaStatus, this.employeerName, + this.occupation, this.sourceOfFund, this.monthlyIncome, this.mobile, @@ -193,6 +208,7 @@ public class ExistingPersonalInfoDTO { return new ExistingPersonalInfoDTO( this.visaStatus, Utils.formatToUpperCaseSafely(this.employeerName), + this.occupation, this.sourceOfFund, this.monthlyIncome, Utils.formatToUpperCaseSafely(this.mobile), @@ -212,6 +228,9 @@ public class ExistingPersonalInfoDTO { public boolean isSourceOfFundValid() { return Utils.isStringNotNullOrEmpty(this.sourceOfFund); } + public boolean isOccupationValid() { + return Utils.isStringNotNullOrEmpty(this.occupation); + } public boolean isMonthlyIncomeValid() { return Utils.isStringNotNullOrEmpty(this.monthlyIncome); diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java index 3fbb1455..149a11e8 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java @@ -22,6 +22,7 @@ public interface ExistingKYCV3PresenterInterface extends BasePresenterInterface void getKycRelatedData(); + List getOccupationList(); List getSourceOfFundList(); List getMonthlyIncomeList(); List getBusinessTypeList(); diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java index b9a66be8..209d12f0 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java @@ -116,6 +116,7 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC private void bindCustomerDetailView(ExistingCustomerDetailViewLiveData.CustomerDetailViewBinding viewBindings) { List> list = Arrays.asList( + viewBindings.getOccupationObservable().map(validator::validateOccupation), viewBindings.getSourceOfFundObservable().map(validator::validateSourceOfFund), viewBindings.getAddressObservable().map(validator::validateAddress), viewBindings.getBusinessTypeObservable().map(validator::validateBusineesType), @@ -212,6 +213,7 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC mobileNumber= mobileNumber.substring(3); } customerDetailLiveData.getEmployerNameLiveData().postValue(new FormInputStateDTO<>(true, null, existingPersonalInfoDTO.getEmployeerName())); + customerDetailLiveData.getOccupationsLiveData().postValue(new FormInputStateDTO<>(true, null, data.getOccupationFromId(existingPersonalInfoDTO.getOccupation()))); customerDetailLiveData.getSourceOfFundLiveData().postValue(new FormInputStateDTO<>(true, null, data.getSourceOfFundFromId(existingPersonalInfoDTO.getSourceOfFund()))); customerDetailLiveData.getMonthlyIncomeLiveData().postValue(new FormInputStateDTO<>(true, null, data.getMonthlyIncomeFromId(existingPersonalInfoDTO.getMonthlyIncome()))); customerDetailLiveData.getBusinessTypeLiveData().postValue(new FormInputStateDTO<>(true, null, data.getBusinessTypeFromId(existingPersonalInfoDTO.getBusinessType()))); @@ -419,6 +421,11 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC ); } + @Override + public List getOccupationList() { + return validator.getExistingKycRelatedDataDTO().getOccupationList(); + } + @Override public List getSourceOfFundList() { @@ -497,7 +504,7 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC view.lazyLoadForms(); if (t.getData().areAnyPicturesAvailableFromServer()) view.showDocumentDetailForm(); - /* onReceivingKycRelatedData(gateway.getMockedData()); + /* onReceivingKycRelatedData(gateway.getMockedData()); view.lazyLoadForms(); if (true) view.showDocumentDetailForm();*/ @@ -552,6 +559,19 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC return existingKycRelatedDataDTO.getFullFormPostData(userId); } + boolean validateOccupation(ExistingIDTextDTO data) { + if (existingKycRelatedDataDTO.getPersonalInformation() == null) + existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + + existingKycRelatedDataDTO.getPersonalInformation().setOccupation(data.getId()); + if (existingKycRelatedDataDTO.getPersonalInformation().isOccupationValid()) { + return true; + } else { + customerDetailLiveData.getOccupationsLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getString(R.string.invalidOccupation), null)); + return false; + } + } + boolean validateSourceOfFund(ExistingIDTextDTO data) { if (existingKycRelatedDataDTO.getPersonalInformation() == null) existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java index e77aebc3..b0497ef4 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java @@ -57,6 +57,10 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis @BindView(R.id.ed_employerName) EditText ed_employerName; + @BindView(R.id.ed_occupation) + EditText ed_occupation; + + @BindView(R.id.ed_sourceOfFund) EditText ed_sourceOfFund; @@ -96,6 +100,7 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis Button btnSubmit1; + private GenericTextListingDialog occupationSelectionDialog; private GenericTextListingDialog sourceOfFundSelectionDialog; private GenericTextListingDialog monthlyIncomeSelectionDialog; private GenericTextListingDialog busineessTypeSelectionDialog; @@ -103,6 +108,7 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis private GenericTextListingDialog idTypeSelectionDialog; private GenericTextListingDialog visaStatusSelectionDialog; + private PublishSubject occupationSelectSubject; private PublishSubject sourceOfFundSelectSubject; private PublishSubject monthlyIncomeSelectSubject; private PublishSubject businessTypeSelectSubject; @@ -130,6 +136,7 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis private void init() { + occupationSelectSubject = PublishSubject.create(); sourceOfFundSelectSubject = PublishSubject.create(); monthlyIncomeSelectSubject = PublishSubject.create(); businessTypeSelectSubject = PublishSubject.create(); @@ -140,6 +147,7 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis customerDetailViewBinding = new ExistingCustomerDetailViewLiveData.CustomerDetailViewBinding( RxTextView.textChanges(ed_employerName).skipInitialValue(), + occupationSelectSubject, sourceOfFundSelectSubject, monthlyIncomeSelectSubject, RxTextView.textChanges(ed_mobileNumber).skipInitialValue(), @@ -164,13 +172,22 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis existingCustomerDetailViewLiveData.getMonthlyIncomeLiveData().observe(getViewLifecycleOwner(), this::onMonthlyIncomeSelected); existingCustomerDetailViewLiveData.getEmployerNameLiveData().observe(getViewLifecycleOwner(), this::onEmployerNameSelected); existingCustomerDetailViewLiveData.getSourceOfFundLiveData().observe(getViewLifecycleOwner(), this::onSourceOfFundSelected); + existingCustomerDetailViewLiveData.getOccupationsLiveData().observe(getViewLifecycleOwner(), this::onOccupationSelected); existingCustomerDetailViewLiveData.getVisaStatusLiveData().observe(getViewLifecycleOwner(), this::onVisaStatusSelected); existingCustomerDetailViewLiveData.getAllFieldsValidLiveData().observe(getViewLifecycleOwner(), areAllFieldsValid -> btnSubmit1.setEnabled(areAllFieldsValid)); } - private void onSourceOfFundSelected(FormInputStateDTO data) { + private void onOccupationSelected(FormInputStateDTO data) { + if (data.isValid()) { + if (data.hasData()) { + ed_occupation.setText(data.getData().getText()); + occupationSelectSubject.onNext(data.getData()); + } + } + } + private void onSourceOfFundSelected(FormInputStateDTO data) { if (data.isValid()) { if (data.hasData()) { ed_sourceOfFund.setText(data.getData().getText()); @@ -406,6 +423,26 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis if (!sourceOfFundSelectionDialog.isAdded()) sourceOfFundSelectionDialog.show(getActivity().getSupportFragmentManager(), "SOURCEOFFUNDTYPECHOOSER"); } + @OnClick(R.id.ed_occupation) + public void promptOccupation() { + hideKeyBoard(); + if (occupationSelectionDialog == null) + occupationSelectionDialog = new GenericTextListingDialog<>(); + + + occupationSelectionDialog.setData(kycv3ViewModel.getOccupationList()); + occupationSelectionDialog.disableSearch(true); + occupationSelectionDialog.setListener(occupation -> + { + occupationSelectionDialog.dismiss(); + ed_occupation.setText(occupation.toString()); + occupationSelectSubject.onNext(occupation); + }); + + occupationSelectionDialog.setHintAndTitle(getString(R.string.searchOccupation), getString(R.string.selectOccupation), getString(R.string.no_result_found_text)); + if (!occupationSelectionDialog.isAdded()) + occupationSelectionDialog.show(getActivity().getSupportFragmentManager(), "OCCUPATIONCHOOSER"); + } @OnClick(R.id.ed_monthlyIncome) public void promptMonthlyIncome() { diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java index ba01cf88..6a19047e 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java @@ -11,6 +11,7 @@ import io.reactivex.Observable; public class ExistingCustomerDetailViewLiveData { private MutableLiveData> employerNameLiveData; + private MutableLiveData> occupationsLiveData; private MutableLiveData> sourceOfFundLiveData; private MutableLiveData> monthlyIncomeLiveData; private MutableLiveData> mobileNumberLiveData; @@ -24,6 +25,7 @@ public class ExistingCustomerDetailViewLiveData { public ExistingCustomerDetailViewLiveData() { employerNameLiveData = new MutableLiveData<>(); sourceOfFundLiveData = new MutableLiveData<>(); + occupationsLiveData = new MutableLiveData<>(); monthlyIncomeLiveData = new MutableLiveData<>(); mobileNumberLiveData = new MutableLiveData<>(); businessTypeLiveData = new MutableLiveData<>(); @@ -34,6 +36,14 @@ public class ExistingCustomerDetailViewLiveData { allFieldsValid = new MutableLiveData<>(); } + public MutableLiveData> getOccupationsLiveData() { + return occupationsLiveData; + } + + public void setOccupationsLiveData(MutableLiveData> occupationsLiveData) { + this.occupationsLiveData = occupationsLiveData; + } + public MutableLiveData> getEmployerNameLiveData() { return employerNameLiveData; } @@ -125,6 +135,7 @@ public class ExistingCustomerDetailViewLiveData { public static class CustomerDetailViewBinding { private Observable employerNameObservable; + private Observable occupationObservable; private Observable sourceOfFundObservable; private Observable monthlyIncomeObservable; private Observable mobileNumberObservable; @@ -136,6 +147,7 @@ public class ExistingCustomerDetailViewLiveData { public CustomerDetailViewBinding( Observable employerNameObservable, + Observable occupationObservable, Observable sourceOfFundObservable, Observable monthlyIncomeObservable, Observable mobileNumberObservable, @@ -149,6 +161,7 @@ public class ExistingCustomerDetailViewLiveData { this.employerNameObservable = employerNameObservable; this.sourceOfFundObservable = sourceOfFundObservable; + this.occupationObservable = occupationObservable; this.monthlyIncomeObservable = monthlyIncomeObservable; this.mobileNumberObservable = mobileNumberObservable; this.businessTypeObservable = businessTypeObservable; @@ -193,5 +206,9 @@ public class ExistingCustomerDetailViewLiveData { public Observable getVisaStatusObservable() { return visaStatusObservable; } + + public Observable getOccupationObservable() { + return occupationObservable; + } } } diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java index c23b93da..c2b5909f 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java @@ -96,7 +96,6 @@ public class KYCV3Gateway extends PrivilegedGateway implements KYCV3GatewayInter createImageUploadFieldFromFile("additionalId", additionalIdImageFile), createImageUploadFieldFromFile("additionalIdBack", additionalIdBackImageFile) ); - } diff --git a/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml b/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml index 322458dc..3db9822c 100644 --- a/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml +++ b/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml @@ -57,6 +57,20 @@ + + + + + Invalid Additional ID Image Invalid Additional ID Front Image Invalid Additional ID Back Image + \"Search Occupation \" + Select Occupation + Invalid Occupation