diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/VersamentoMerceViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/VersamentoMerceViewModel.java index a49654b7..22dabfba 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/VersamentoMerceViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/VersamentoMerceViewModel.java @@ -91,14 +91,22 @@ public class VersamentoMerceViewModel { if (!UtilityString.equalsIgnoreCase(mCurrentMtbColt.getValue().getCodMdep(), foundPosizione.getCodMdep())) { this.sendOnSpostamentoTraDepConfirmRequired(mCurrentMtbColt.getValue().getCodMdep(), foundPosizione.getCodMdep(), canContinue -> { + onComplete.run(); if (canContinue) { - updatePosizione(foundPosizione, UtilityPosizione.isPosizioneWithLivello(foundPosizione)); - } else { - onComplete.run(); + if (UtilityPosizione.isPosizioneWithLivello(foundPosizione)) { + askLivelloPosizione(foundPosizione); + } else { + updatePosizione(foundPosizione); + } } }); } else { - updatePosizione(foundPosizione, UtilityPosizione.isPosizioneWithLivello(foundPosizione)); + onComplete.run(); + if (UtilityPosizione.isPosizioneWithLivello(foundPosizione)) { + askLivelloPosizione(foundPosizione); + } else { + updatePosizione(foundPosizione); + } } } @@ -239,26 +247,23 @@ public class VersamentoMerceViewModel { } - public void updatePosizione(MtbDepoPosizione mtbDepoPosizione, boolean shouldAskLivello) { + public void askLivelloPosizione(MtbDepoPosizione mtbDepoPosizione) { + this.sendOnLivelloPosizioneRequired(mtbDepoPosizione, newPosizione -> { + if (newPosizione == null) { + askLivelloPosizione(mtbDepoPosizione); + } else { + updatePosizione(newPosizione); + } - if (shouldAskLivello) { - this.sendOnLivelloPosizioneRequired(mtbDepoPosizione, newPosizione -> { - - if (newPosizione == null) { - updatePosizione(mtbDepoPosizione, shouldAskLivello); - } else { - updatePosizione(newPosizione, false); - } - - }); - } else { - this.sendOnLoadingStarted(); - mColliMagazzinoRESTConsumer.changePosizione(mCurrentMtbColt.getValue(), mtbDepoPosizione, () -> { - this.sendOnLoadingEnded(); - this.sendOnDataSaved(); - }, this::sendError); - } + }); + } + public void updatePosizione(MtbDepoPosizione mtbDepoPosizione) { + this.sendOnLoadingStarted(); + mColliMagazzinoRESTConsumer.changePosizione(mCurrentMtbColt.getValue(), mtbDepoPosizione, () -> { + this.sendOnLoadingEnded(); + this.sendOnDataSaved(); + }, this::sendError); }