Browse Source

CCDI validation on Button click

new_design
Santosh Bhandary 3 years ago
parent
commit
706275b5f0
  1. 20
      app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/model/ccdi/CCDIDataDto.java
  2. 4
      app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/presenter/SendMoneyV2PresenterInterface.java
  3. 36
      app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/presenter/SendMoneyV2ViewModel.java
  4. 12
      app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/SendMoneyV2Activity.java
  5. 19
      app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/ccdi/CCDISendMoneyFragment.java
  6. 4
      app/src/main/res/layout/activity_change_pass_n_pin_layout.xml
  7. 1
      app/src/main/res/layout/fragment_ccdi_send_money_v2.xml
  8. 1
      app/src/main/res/values/strings.xml

20
app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/model/ccdi/CCDIDataDto.java

@ -33,6 +33,10 @@ public class CCDIDataDto {
@Expose
private String otherPurposeOfRemittance="";
private IDTextDTO sourceOfFundModel;
private IDTextDTO purposeOfRemittanceModel;
public String getUserId() {
return userId;
}
@ -88,4 +92,20 @@ public class CCDIDataDto {
public void setOtherPurposeOfRemittance(String otherPurposeOfRemittance) {
this.otherPurposeOfRemittance = otherPurposeOfRemittance;
}
public IDTextDTO getSourceOfFundModel() {
return sourceOfFundModel;
}
public void setSourceOfFundModel(IDTextDTO sourceOfFundModel) {
this.sourceOfFundModel = sourceOfFundModel;
}
public IDTextDTO getPurposeOfRemittanceModel() {
return purposeOfRemittanceModel;
}
public void setPurposeOfRemittanceModel(IDTextDTO purposeOfRemittanceModel) {
this.purposeOfRemittanceModel = purposeOfRemittanceModel;
}
}

4
app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/presenter/SendMoneyV2PresenterInterface.java

@ -67,6 +67,10 @@ public interface SendMoneyV2PresenterInterface extends BasePresenterInterface {
WebRequestModel getWebRequestDataForFraudWarning();
boolean validateAllCCDiForm();
void clearCCDIFormData();
interface SendMoneyV2ContractInterface extends BaseContractInterface
{

36
app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/presenter/SendMoneyV2ViewModel.java

@ -190,6 +190,26 @@ public class SendMoneyV2ViewModel extends BaseViewModel implements SendMoneyV2Pr
return new WebRequestModel("", JME_TERMS_N_CONDITIONS, null);
}
@Override
public boolean validateAllCCDiForm() {
if(ccdiValidator.getCcdiDataDto().getSourceOfFundModel()!=null&&ccdiValidator.getCcdiDataDto().getPurposeOfRemittanceModel()!=null){
ccdiValidator.validateSourceOfFund(ccdiValidator.getCcdiDataDto().getSourceOfFundModel());
ccdiValidator.validatePurposeOfRemit(ccdiValidator.getCcdiDataDto().getPurposeOfRemittanceModel());
return true;
}else{
ccdiValidator.validateSourceOfFund(ccdiValidator.getCcdiDataDto().getSourceOfFundModel());
ccdiValidator.validatePurposeOfRemit(ccdiValidator.getCcdiDataDto().getPurposeOfRemittanceModel());
return false;
}
}
@Override
public void clearCCDIFormData() {
ccdiValidator.getCcdiDataDto().setSourceOfFundModel(null);
ccdiValidator.getCcdiDataDto().setPurposeOfRemittanceModel(null);
}
private String calculatedDiscountedServiceFee() {
return selectedTransferFee;
}
@ -565,6 +585,11 @@ public class SendMoneyV2ViewModel extends BaseViewModel implements SendMoneyV2Pr
}
boolean validateSourceOfFund(IDTextDTO data) {
if(data==null){
ccidDetailViewLiveData.getSourceOfFundLiveData().postValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.InvalidSourceOfFund_text), null));
return false;
}
if (shouldPromptToInputAnswer(data)) {
view.promptToInputAnswer(view.getContext().getResources().getString(R.string.specifySourceOfFund_text), new AnswerInputDialog.AnswerInputDialogListener() {
@ -572,10 +597,12 @@ public class SendMoneyV2ViewModel extends BaseViewModel implements SendMoneyV2Pr
public void onAnswerSubmitted(String answer) {
ccdiDataDto.setOtherSourceOfFund(answer);
ccdiDataDto.setSourceOfFund("");
ccdiDataDto.setSourceOfFundModel(new IDTextDTO(answer,answer));
ccidDetailViewLiveData.getSourceOfFundLiveData().postValue(new FormInputStateDTO<>(true, null, IDTextDTO.createFromUserAnswerInput(answer)));
}
});
} else {
ccdiDataDto.setSourceOfFundModel(data);
if (!data.getId().equalsIgnoreCase(data.getText())) {
ccdiDataDto.setSourceOfFund(data.getId());
ccdiDataDto.setOtherSourceOfFund("");
@ -586,6 +613,7 @@ public class SendMoneyV2ViewModel extends BaseViewModel implements SendMoneyV2Pr
}
if (Utils.isStringNotNullOrEmpty(ccdiDataDto.getSourceOfFund()) || Utils.isStringNotNullOrEmpty(ccdiDataDto.getOtherSourceOfFund())) {
ccidDetailViewLiveData.getSourceOfFundLiveData().postValue(new FormInputStateDTO<>(true, null, null));
return true;
} else {
ccidDetailViewLiveData.getSourceOfFundLiveData().postValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.InvalidSourceOfFund_text), null));
@ -594,16 +622,21 @@ public class SendMoneyV2ViewModel extends BaseViewModel implements SendMoneyV2Pr
}
private boolean validatePurposeOfRemit(IDTextDTO data) {
if(data==null){
ccidDetailViewLiveData.getPurposeOfRemittanceLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidPurposeOfRemittance), null));
return false;
}
if (shouldPromptToInputAnswer(data)) {
view.promptToInputAnswer(view.getContext().getResources().getString(R.string.specifyPurposeOfRemit_text), new AnswerInputDialog.AnswerInputDialogListener() {
@Override
public void onAnswerSubmitted(String answer) {
ccdiDataDto.setOtherPurposeOfRemittance(answer);
ccidDetailViewLiveData.getPurposeOfRemittanceLiveData().postValue(new FormInputStateDTO<>(true, null, IDTextDTO.createFromUserAnswerInput(answer)));
ccdiDataDto.setPurposeOfRemittanceModel(new IDTextDTO(answer,answer));
}
});
} else {
ccdiDataDto.setPurposeOfRemittanceModel(data);
if (!data.getId().equalsIgnoreCase(data.getText())) {
ccdiDataDto.setPurposeOfRemittance(data.getId());
ccdiDataDto.setOtherPurposeOfRemittance("");
@ -614,6 +647,7 @@ public class SendMoneyV2ViewModel extends BaseViewModel implements SendMoneyV2Pr
}
if (Utils.isStringNotNullOrEmpty(ccdiDataDto.getPurposeOfRemittance()) || Utils.isStringNotNullOrEmpty(ccdiDataDto.getOtherPurposeOfRemittance())) {
ccidDetailViewLiveData.getPurposeOfRemittanceLiveData().postValue(new FormInputStateDTO<>(true, null, null));
return true;
} else {
ccidDetailViewLiveData.getPurposeOfRemittanceLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidPurposeOfRemittance), null));

12
app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/SendMoneyV2Activity.java

@ -2,6 +2,7 @@ package com.swifttech.remit.jmecustomer.features.sendmoney.view;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@ -135,7 +136,11 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction
}
public boolean popFragmentFromStack() {
return fragmentManager.getBackStackEntryCount() > 0 ;
if (fragmentManager.getBackStackEntryCount() == 1) {
Log.d("===", "CCDI data cleared : ");
presenter.clearCCDIFormData();
}
return fragmentManager.getBackStackEntryCount() > 0;
}
@ -287,9 +292,9 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction
@Override
public void onBackPressed() {
hideKeyBoard();
if(popFragmentFromStack()){
if (popFragmentFromStack()) {
super.onBackPressed();
}else{
} else {
Intent intent = new Intent(this, RecipientListingV3Activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
@ -333,6 +338,7 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction
answerInputDialog.show(getSupportFragmentManager(), answerInputDialog.getClass().getSimpleName());
}
@Override
public void updateFinalTranstionToDefault(int layoutId) {
switch (layoutId) {

19
app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/ccdi/CCDISendMoneyFragment.java

@ -61,7 +61,7 @@ public class CCDISendMoneyFragment extends BaseFragment implements View.OnClickL
));
ccidDetailViewLiveData.getSourceOfFundLiveData().observe(getViewLifecycleOwner(), this::onSourceOfFundSelected);
ccidDetailViewLiveData.getPurposeOfRemittanceLiveData().observe(getViewLifecycleOwner(), this::onPurposeOfRemittSelected);
ccidDetailViewLiveData.getPurposeOfRemittanceLiveData().observe(getViewLifecycleOwner(), this::onPurposeOfRemitSelected);
ccidDetailViewLiveData.getAllFormValidLiveData().observe(getViewLifecycleOwner(), result -> binding.btnContinue.setEnabled(result.isValid()));
viewModel.getCCidRelatedData();
}
@ -113,7 +113,10 @@ public class CCDISendMoneyFragment extends BaseFragment implements View.OnClickL
switch (view.getId()) {
case R.id.btnContinue:
((SendMoneyActionListener) getActivity()).showTransactionReviewPage();
if(viewModel.validateAllCCDiForm()){
((SendMoneyActionListener) getActivity()).showTransactionReviewPage();
}
break;
case R.id.ed_sourceOfFund:
if(viewModel.getSourceOfFundList().size()>0){
@ -193,6 +196,8 @@ public class CCDISendMoneyFragment extends BaseFragment implements View.OnClickL
private void onSourceOfFundSelected(FormInputStateDTO<IDTextDTO> data) {
if (data.isValid()) {
binding.sourceOfFundSelectionWrapper.setErrorEnabled(false);
binding.sourceOfFundSelectionWrapper.setError(null);
if (data.hasData()) {
if(!data.getData().getText().equalsIgnoreCase(getString(R.string.othersSpecify))
&& !data.getData().getText().equalsIgnoreCase(getString(R.string.othersSpecify1))
@ -202,10 +207,15 @@ public class CCDISendMoneyFragment extends BaseFragment implements View.OnClickL
}
sourceOfFundSelectSubject.onNext(data.getData());
}
}else{
binding.sourceOfFundSelectionWrapper.setErrorEnabled(true);
binding.sourceOfFundSelectionWrapper.setError(getString(R.string.invalidSourceOfFund_text));
}
}
private void onPurposeOfRemittSelected(FormInputStateDTO<IDTextDTO> data) {
private void onPurposeOfRemitSelected(FormInputStateDTO<IDTextDTO> data) {
if (data.isValid()) {
binding.receiverTransferReasonSelectionWrapper.setErrorEnabled(false);
binding.receiverTransferReasonSelectionWrapper.setError(null);
if (data.hasData()) {
if(!data.getData().getText().equalsIgnoreCase(getString(R.string.othersSpecify))
&& !data.getData().getText().equalsIgnoreCase(getString(R.string.othersSpecify1))
@ -215,6 +225,9 @@ public class CCDISendMoneyFragment extends BaseFragment implements View.OnClickL
}
purposeOfRemittanceSelectSubject.onNext(data.getData());
}
}else{
binding.receiverTransferReasonSelectionWrapper.setErrorEnabled(true);
binding.receiverTransferReasonSelectionWrapper.setError(getString(R.string.invalidPurposeOfRemittance));
}
}
}

4
app/src/main/res/layout/activity_change_pass_n_pin_layout.xml

@ -138,6 +138,4 @@
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>

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

@ -64,6 +64,7 @@
<com.swifttech.remit.jmecustomer.common.customwidgets.GmeButton
android:id="@+id/btnContinue"
style="@style/MButton"
android:enabled="true"
android:layout_gravity="center"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginBottom="@dimen/_15sdp"

1
app/src/main/res/values/strings.xml

@ -1070,5 +1070,6 @@ All the configurations are done from backend web application system which allows
<string name="invalidDistrict_text">Invalid District</string>
<string name="invalidRelation_text">Invalid Relation</string>
<string name="pleaseFillFormToProceed_text">Please fill form to proceed</string>
<string name="invalidSourceOfFund_text">Invalid Source of Fund</string>
</resources>
Loading…
Cancel
Save