Controllo documenti fruma

This commit is contained in:
Marco Elefante 2024-06-17 17:53:46 +02:00
parent bdbecfb037
commit 022841c195
4 changed files with 80 additions and 11 deletions

View File

@ -2,6 +2,7 @@ package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import java.util.Date;
import java.util.List;
import javax.inject.Singleton;
@ -18,7 +19,7 @@ import retrofit2.Response;
@Singleton
public class DocumentRESTConsumer extends _BaseRESTConsumer {
public void createDocsFromColli(List<LoadColliDTO> listColli, RunnableArgs<List<DtbDoct>> onComplete, RunnableArgs<Exception> onFailed) {
DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
@ -50,8 +51,21 @@ public class DocumentRESTConsumer extends _BaseRESTConsumer {
});
}
public void checkFrumaDocument(String fornitore, String numDoc, String dataDoc, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.checkFrumaDoc(fornitore, numDoc, dataDoc)
.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<ServiceRESTResponse<Boolean>> call, @NonNull Response<ServiceRESTResponse<Boolean>> response) {
analyzeAnswer(response, "checkDocument", onComplete, onFailed);
}
@Override
public void onFailure(@NonNull Call<ServiceRESTResponse<Boolean>> call, @NonNull Throwable t) {
onFailed.run(new Exception(t));
}
});
}
public void loadDocumentAvailableArts(String codDtip, String codMgrp, String codAnagForn, RunnableArgs<RetrieveDocumentoArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);

View File

@ -1,5 +1,6 @@
package it.integry.integrywmsnative.core.rest.consumers;
import java.util.Date;
import java.util.List;
import it.integry.integrywmsnative.core.model.DtbDoct;
@ -20,8 +21,11 @@ public interface DocumentiRESTConsumerService {
@POST("createDocFromColli")
Call<ServiceRESTResponse<DtbDoct>> createDocFromColli(@Body LoadColliDTO listColli);
@GET("wms/documento/checkFruma")
Call<ServiceRESTResponse<Boolean>> checkFrumaDoc(
@Query("fornitore") String fornitore,
@Query("numDoc") String numDoc,
@Query("dataDoc") String dataDoc);
@GET("wms/documento/arts")
Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> retrieveArts(

View File

@ -3,6 +3,8 @@ package it.integry.integrywmsnative.gest.contab_doc_interni;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -37,6 +39,7 @@ import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.DocInterniE
import it.integry.integrywmsnative.gest.contab_doc_interni.ui.DocInterniListAdapter;
import it.integry.integrywmsnative.gest.contab_doc_interni.ui.DocInterniListModel;
import it.integry.integrywmsnative.ui.ElevatedToolbar;
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
public class DocInterniFragment extends BaseFragment implements ITitledFragment, IScrollableFragment, DocInterniViewModel.Listener {
@ -120,10 +123,21 @@ public class DocInterniFragment extends BaseFragment implements ITitledFragment,
this.openDocumentSelectionDialog();
}
@Override
public void onWarning(String warningText, Runnable action) {
this.requireActivity().runOnUiThread(() -> {
this.onLoadingEnded();
DialogSimpleMessageView
.makeWarningDialog(new SpannableString(Html.fromHtml(warningText)), null, action)
.show(requireActivity().getSupportFragmentManager(), "tag");
});
}
@Override
public void onDocDetailsChanged(DialogSelectDocInfoResponseDTO selection) {
mViewModel.setSelectedDocDetails(selection);
mBinding.invalidateAll();
mViewModel.setSelectedDocDetails(selection, () -> {
mBinding.invalidateAll();
});
}
@Override

View File

@ -8,16 +8,22 @@ import java.util.List;
import javax.inject.Inject;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColtRepository;
import it.integry.integrywmsnative.core.data_store.db.wrappers.DocInternoWrapper;
import it.integry.integrywmsnative.core.di.BindableInteger;
import it.integry.integrywmsnative.core.exception.NoDocFoundException;
import it.integry.integrywmsnative.core.exception.NoDocTypeSelectedException;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.documento.DocumentoArtDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityResources;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.DialogSelectDocInfoResponseDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.exception.DocumentRequiredException;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.FornitoreDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GruppoArticoloDTO;
@ -76,6 +82,14 @@ public class DocInterniViewModel {
if (this.mListener != null) mListener.onError(ex);
}
private void sendWarning(String warningText, Runnable action) {
if (this.mListener != null) mListener.onWarning(warningText, action);
}
private void sendDocDetailsChanged(DialogSelectDocInfoResponseDTO selection){
if (this.mListener != null) mListener.onDocDetailsChanged(selection);
}
public DocInterniViewModel setListeners(Listener listener) {
this.mListener = listener;
return this;
@ -85,7 +99,7 @@ public class DocInterniViewModel {
return mDocsList;
}
public void setSelectedDocDetails(DialogSelectDocInfoResponseDTO selection) {
public void setSelectedDocDetails(DialogSelectDocInfoResponseDTO selection, Runnable action) {
this.fornitore = selection.getFornitore();
this.dtbTipi = selection.getTipoDoc();
@ -94,10 +108,31 @@ public class DocInterniViewModel {
this.numDoc = selection.getNumDoc() != null ? selection.getNumDoc().toString() : null;
this.note = selection.getNote();
this.sendOnLoadingStarted();
fetchProducts(() -> {
fetchDocuments(this::sendOnLoadingEnded);
});
if (dtbTipi.getCodDtip().equalsIgnoreCase("FRUMA")) {
documentRESTConsumer.checkFrumaDocument(
fornitore.getCodAnag(),
numDoc,
UtilityDate.formatDate(dataDoc, "yyyy/MM/dd"),
data -> {
if (!data) {
this.sendWarning(UtilityResources.getString(R.string.no_doc_found_message), this::init);
} else {
action.run();
this.sendOnLoadingStarted();
fetchProducts(() -> {
fetchDocuments(this::sendOnLoadingEnded);
});
}
},
this::sendError
);
} else {
action.run();
this.sendOnLoadingStarted();
fetchProducts(() -> {
fetchDocuments(this::sendOnLoadingEnded);
});
}
}
public void fetchProducts(Runnable onComplete) {
@ -210,6 +245,8 @@ public class DocInterniViewModel {
void onError(Exception ex);
void onWarning(String warningText, Runnable action);
void onDocInterniSetupFetched(DocInterniSetupDTO docInterniSetupDTO);
void onDocDetailsChanged(DialogSelectDocInfoResponseDTO selection);