diff --git a/app/build.gradle b/app/build.gradle index 3c966238..d364476a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ apply plugin: 'com.google.gms.google-services' android { - def appVersionCode = 177 - def appVersionName = '1.14.0' + def appVersionCode = 178 + def appVersionName = '1.14.1' signingConfigs { release { @@ -91,7 +91,7 @@ dependencies { //Firebase // Import the Firebase BoM - implementation platform('com.google.firebase:firebase-bom:26.0.0') + implementation platform('com.google.firebase:firebase-bom:26.3.0') implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-core' implementation 'com.google.firebase:firebase-crash' @@ -102,7 +102,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'com.google.android.material:material:1.3.0-alpha04' + implementation 'com.google.android.material:material:1.3.0-rc01' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' diff --git a/app/src/main/java/it/integry/integrywmsnative/core/expansion/RunnableArgsWithReturn.java b/app/src/main/java/it/integry/integrywmsnative/core/expansion/RunnableArgsWithReturn.java new file mode 100644 index 00000000..c569a9b5 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/core/expansion/RunnableArgsWithReturn.java @@ -0,0 +1,7 @@ +package it.integry.integrywmsnative.core.expansion; + +public interface RunnableArgsWithReturn { + + R run(T data); + +} \ No newline at end of file diff --git a/app/src/main/java/it/integry/integrywmsnative/core/model/MtbColt.java b/app/src/main/java/it/integry/integrywmsnative/core/model/MtbColt.java index 62a45af4..c2ccf5be 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/model/MtbColt.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/model/MtbColt.java @@ -54,6 +54,7 @@ public class MtbColt extends EntityBase { private BigDecimal lunghezzaCm; private BigDecimal larghezzaCm; private BigDecimal altezzaCm; + private String codJcom; private List mtbCols; @@ -500,6 +501,15 @@ public class MtbColt extends EntityBase { return this; } + public String getCodJcom() { + return codJcom; + } + + public MtbColt setCodJcom(String codJcom) { + this.codJcom = codJcom; + return this; + } + public void generaFiltroOrdineFromDTO(List filtroOrdineDtos) { String xmlPrefix = "{\"whereCond\": \""; diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java index 9309145a..5d650b95 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PosizioniRESTConsumer.java @@ -44,7 +44,7 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer{ public static void getBancaliInPosizione(MtbDepoPosizione mtbDepoPosizione, RunnableArgs> onComplete, RunnableArgs onFailed) { - String sql = "SELECT * FROM mtb_colt WHERE cod_mdep = " + UtilityDB.valueToString(mtbDepoPosizione.getCodMdep()) + " AND posizione = " + UtilityDB.valueToString(mtbDepoPosizione.getPosizione()); + String sql = "SELECT * FROM mtb_colt WHERE segno > 0 AND cod_mdep = " + UtilityDB.valueToString(mtbDepoPosizione.getCodMdep()) + " AND posizione = " + UtilityDB.valueToString(mtbDepoPosizione.getPosizione()); Type typeOfObjectsList = new TypeToken>() {}.getType(); diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingActivity.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingActivity.java index 22994dce..4c867d49 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingActivity.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingActivity.java @@ -52,6 +52,7 @@ import it.integry.integrywmsnative.gest.accettazione_picking.core.AccettazioneLi import it.integry.integrywmsnative.gest.accettazione_picking.core.AccettazioneListModel; import it.integry.integrywmsnative.gest.accettazione_picking.dto.AccettazioneOrdineInevasoOrderBy; import it.integry.integrywmsnative.gest.accettazione_picking.dto.PickingObjectDTO; +import it.integry.integrywmsnative.gest.accettazione_picking.rest.RecoverMtbColt; import it.integry.integrywmsnative.gest.lista_bancali.ListaBancaliActivity; import it.integry.integrywmsnative.gest.spedizione.exceptions.InvalidPesoKGException; import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO; @@ -455,8 +456,13 @@ public class AccettazionePickingActivity extends BaseActivity implements Accetta } - public void startListaBancaliRegistratiActivity(ArrayList mtbColts){ - Intent myIntent = ListaBancaliActivity.createIntent(this, mtbColts, false, PrinterRESTConsumer.Type.SECONDARIA, ReportManager.getReportNameLUFromGestione(GestioneEnum.ACQUISTO)); + public void startListaBancaliRegistratiActivity(ArrayList mtbColts) { + + Intent myIntent = ListaBancaliActivity.createIntent(this, + Stream.of(mtbColts).map(x -> (MtbColt)x).toList(), + input -> ((RecoverMtbColt) input).isFlagCanBeRecovered(), + PrinterRESTConsumer.Type.SECONDARIA, + ReportManager.getReportNameLUFromGestione(GestioneEnum.ACQUISTO)); this.startActivityForResult(myIntent, PICK_UL_REQUEST); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java index ef9ad593..672b1c39 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java @@ -54,6 +54,7 @@ import it.integry.integrywmsnative.gest.accettazione.dto.SitArtOrdDTO; import it.integry.integrywmsnative.gest.accettazione_picking.dto.HistoryMtbAartDTO; import it.integry.integrywmsnative.gest.accettazione_picking.dto.PickingObjectDTO; import it.integry.integrywmsnative.gest.accettazione_picking.rest.AccettazionePickingRESTConsumer; +import it.integry.integrywmsnative.gest.accettazione_picking.rest.RecoverMtbColt; import it.integry.integrywmsnative.gest.spedizione.exceptions.InvalidPesoKGException; import it.integry.integrywmsnative.gest.spedizione.exceptions.NotCurrentYearLUException; import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO; @@ -165,7 +166,7 @@ public class AccettazionePickingViewModel { return mPickingList; } - public void retrieveExistentLU(RunnableArgs> onComplete) { + public void retrieveExistentLU(RunnableArgs> onComplete) { this.sendOnLoadingStarted(); this.mAccettazionePickingRESTConsumer.getBancaliGiaRegistrati(this.mSitArts, mtbColtList -> { diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/rest/AccettazionePickingRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/rest/AccettazionePickingRESTConsumer.java index c1e5b818..7c4ddf56 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/rest/AccettazionePickingRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/rest/AccettazionePickingRESTConsumer.java @@ -5,18 +5,18 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Date; +import java.util.HashMap; import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; -import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityLogger; +import it.integry.integrywmsnative.core.utility.UtilityQuery; import it.integry.integrywmsnative.gest.accettazione.dto.SitArtOrdDTO; @Singleton @@ -29,56 +29,87 @@ public class AccettazionePickingRESTConsumer { this.mSystemRestConsumer = systemRESTConsumer; } - public void getBancaliGiaRegistrati(List ordiniToShow, RunnableArgs> onComplete, RunnableArgs onFailed) { + public void getBancaliGiaRegistrati(List ordiniToShow, RunnableArgs> onComplete, RunnableArgs onFailed) { + List> whereCondListMap = new ArrayList<>(); - List colliWhereCond = new ArrayList<>(); + Stream + .of(ordiniToShow) + .distinctBy(x -> x.getDataOrd() + " " + x.getGestione() + " " + x.getNumOrd()) + .forEach(x -> { + try { + HashMap whereCondMap = new HashMap<>(); + whereCondMap.put("mtb_colr.data_ord", UtilityDate.recognizeDate(x.getDataOrd())); + whereCondMap.put("mtb_colr.gestione", x.getGestione().equalsIgnoreCase("P") ? "L" : x.getGestione()); + whereCondMap.put("mtb_colr.num_ord", x.getNumOrd()); + + whereCondListMap.add(whereCondMap); + } catch (Exception ex) { + UtilityLogger.errorMe(ex); + } + }); - Stream.of(ordiniToShow).forEach(x -> { - try { - Date date = UtilityDate.recognizeDate(x.getDataOrd()); - String dateString = UtilityDate.formatDate(date, "yyyy/MM/dd"); - - if (!colliWhereCond.contains(x.getGestione() + " " + dateString + " " + x.getNumOrd())) { - String gestione = x.getGestione().equalsIgnoreCase("P") ? "L" : x.getGestione(); - colliWhereCond.add(gestione + " " + dateString + " " + x.getNumOrd()); - } - } catch (Exception ex){ - UtilityLogger.errorMe(ex); - } - }); + String sql = "SELECT DISTINCT CAST(CASE WHEN MAX(ISNULL(mtb_colr_scar.num_collo, 0)) = 0 THEN 1 ELSE 0 END AS BIT) AS flagCanBeRecovered, " + + " mtb_colt.* " + + "FROM mtb_colt" + + " INNER JOIN mtb_colr ON " + + " mtb_colt.gestione = mtb_colr.gestione AND " + + " mtb_colt.ser_collo = mtb_colr.ser_collo AND " + + " mtb_colt.data_collo = mtb_colr.data_collo AND " + + " mtb_colt.num_collo = mtb_colr.num_collo " + + " LEFT OUTER JOIN mtb_colr mtb_colr_scar ON mtb_colr_scar.num_collo_rif = mtb_colr.num_collo AND " + + " mtb_colr_scar.gestione_rif = mtb_colr.gestione AND " + + " mtb_colr_scar.ser_collo_rif = mtb_colr.ser_collo AND " + + " mtb_colr_scar.data_collo_rif = mtb_colr.data_collo " + + " WHERE (" + UtilityQuery.concatFieldListInWhereCond(whereCondListMap) + ") " + + " AND mtb_colt.data_doc IS NULL " + + " GROUP BY mtb_colt.gestione," + + " mtb_colt.data_collo," + + " mtb_colt.num_collo," + + " segno," + + " peso_kg," + + " lunghezza_cm," + + " larghezza_cm," + + " altezza_cm," + + " cod_anag," + + " cod_dtip," + + " mtb_colt.data_doc," + + " mtb_colt.ser_doc," + + " mtb_colt.num_doc," + + " rif_ord," + + " mtb_colt.ser_collo," + + " cod_tcol," + + " mtb_colt.data_ord," + + " mtb_colt.num_ord," + + " cod_vdes," + + " cod_mdep," + + " cod_vlis," + + " preparato_da," + + " ora_iniz_prep," + + " ora_fine_prep," + + " filtro_ordini," + + " annotazioni," + + " posizione," + + " cod_dtip_provv," + + " data_doc_provv," + + " ser_doc_provv," + + " num_doc_provv," + + " cod_jfas," + + " data_vers," + + " mtb_colt.peso_netto_kg"; - StringBuilder colliINCondition = new StringBuilder(); - - for(int i = 0; i < colliWhereCond.size(); i ++){ - colliINCondition.append("'").append(colliWhereCond.get(i)).append("'"); - - if(i < (colliWhereCond.size()-1)) colliINCondition.append(","); - } - - - - String sql = "SELECT DISTINCT mtb_colt.* " + - "FROM mtb_colt, mtb_colr " + - "WHERE mtb_colt.gestione = mtb_colr.gestione AND " + - "mtb_colt.ser_collo = mtb_colr.ser_collo AND " + - "mtb_colt.data_collo = mtb_colr.data_collo AND " + - "mtb_colt.num_collo = mtb_colr.num_collo AND " + - "mtb_colt.gestione + ' ' + CONVERT(VARCHAR(15), mtb_colr.data_ord, 111) + ' ' + CONVERT(VARCHAR, mtb_colr.num_ord) IN (" + colliINCondition + - ") AND mtb_colt.data_doc IS NULL "; - - - Type typeOfObjectsList = new TypeToken>() {}.getType(); - mSystemRestConsumer.processSql(sql, typeOfObjectsList, new ISimpleOperationCallback>() { + Type typeOfObjectsList = new TypeToken>() { + }.getType(); + mSystemRestConsumer.processSql(sql, typeOfObjectsList, new ISimpleOperationCallback>() { @Override - public void onSuccess(ArrayList value) { - if(onComplete != null) onComplete.run(value); + public void onSuccess(ArrayList value) { + if (onComplete != null) onComplete.run(value); } @Override public void onFailed(Exception ex) { - if(onFailed != null) onFailed.run(ex); + if (onFailed != null) onFailed.run(ex); } }); diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/rest/RecoverMtbColt.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/rest/RecoverMtbColt.java new file mode 100644 index 00000000..6fcd5b2d --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/rest/RecoverMtbColt.java @@ -0,0 +1,17 @@ +package it.integry.integrywmsnative.gest.accettazione_picking.rest; + +import it.integry.integrywmsnative.core.model.MtbColt; + +public class RecoverMtbColt extends MtbColt { + + private boolean flagCanBeRecovered; + + public boolean isFlagCanBeRecovered() { + return flagCanBeRecovered; + } + + public RecoverMtbColt setFlagCanBeRecovered(boolean flagCanBeRecovered) { + this.flagCanBeRecovered = flagCanBeRecovered; + return this; + } +} diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/lista_bancali/ListaBancaliActivity.java b/app/src/main/java/it/integry/integrywmsnative/gest/lista_bancali/ListaBancaliActivity.java index d929e473..2cddbae5 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/lista_bancali/ListaBancaliActivity.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/lista_bancali/ListaBancaliActivity.java @@ -6,12 +6,12 @@ import android.os.Bundle; import androidx.databinding.DataBindingUtil; -import java.util.ArrayList; import java.util.List; import it.integry.integrywmsnative.R; import it.integry.integrywmsnative.core.data_cache.DataCache; import it.integry.integrywmsnative.core.expansion.BaseActivity; +import it.integry.integrywmsnative.core.expansion.RunnableArgsWithReturn; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; import it.integry.integrywmsnative.databinding.ActivityListaBancaliBinding; @@ -32,7 +32,7 @@ public class ListaBancaliActivity extends BaseActivity { private ListaBancaliViewModel mViewModel; - private boolean mCanRecoverUl; + private RunnableArgsWithReturn mCanRecoverUl; private PrinterRESTConsumer.Type mPrinterType; private String mReportName; private boolean mFlagOnlyResiduo; @@ -41,34 +41,25 @@ public class ListaBancaliActivity extends BaseActivity { - public static Intent createIntent(Context context, ArrayList items, boolean canRecoverUl, PrinterRESTConsumer.Type printerType, String reportName) { - Intent myIntent = new Intent(context, ListaBancaliActivity.class); - - String mtbColtsKey = DataCache.addItem(items); - myIntent.putExtra(Key.MtbColtsKey, mtbColtsKey); - - String canRecoverULKey = DataCache.addItem(canRecoverUl); - myIntent.putExtra(Key.CanRecoverUL, canRecoverULKey); - - String printerTypeKey = DataCache.addItem(printerType); - myIntent.putExtra(Key.PrinterType, printerTypeKey); - - String reportNameKey = DataCache.addItem(reportName); - myIntent.putExtra(Key.ReportName, reportNameKey); - - String flagOnlyResiduoKey = DataCache.addItem(true); - myIntent.putExtra(Key.FlagOnlyResiduo, flagOnlyResiduoKey); - - return myIntent; + public static Intent createIntent(Context context, List items, RunnableArgsWithReturn canRecoverUlAction, PrinterRESTConsumer.Type printerType, String reportName) { + return createIntent(context, items, canRecoverUlAction, printerType, true, reportName); } - public static Intent createIntent(Context context, ArrayList items, boolean canRecoverUl, PrinterRESTConsumer.Type printerType, boolean onlyResiduo) { + public static Intent createIntent(Context context, List items, boolean canRecoverUl, PrinterRESTConsumer.Type printerType, boolean onlyResiduo) { + return createIntent(context, items, input -> canRecoverUl, printerType, onlyResiduo); + } + + public static Intent createIntent(Context context, List items, RunnableArgsWithReturn canRecoverUlAction, PrinterRESTConsumer.Type printerType, boolean onlyResiduo) { + return createIntent(context, items, canRecoverUlAction, printerType, onlyResiduo, null); + } + + public static Intent createIntent(Context context, List items, RunnableArgsWithReturn canRecoverUlAction, PrinterRESTConsumer.Type printerType, boolean onlyResiduo, String reportName) { Intent myIntent = new Intent(context, ListaBancaliActivity.class); String mtbColtsKey = DataCache.addItem(items); myIntent.putExtra(Key.MtbColtsKey, mtbColtsKey); - String canRecoverULKey = DataCache.addItem(canRecoverUl); + String canRecoverULKey = DataCache.addItem(canRecoverUlAction); myIntent.putExtra(Key.CanRecoverUL, canRecoverULKey); String printerTypeKey = DataCache.addItem(printerType); @@ -77,9 +68,13 @@ public class ListaBancaliActivity extends BaseActivity { String flagOnlyResiduoKey = DataCache.addItem(onlyResiduo); myIntent.putExtra(Key.FlagOnlyResiduo, flagOnlyResiduoKey); + String reportNameKey = DataCache.addItem(reportName); + myIntent.putExtra(Key.ReportName, reportNameKey); + return myIntent; } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -108,7 +103,7 @@ public class ListaBancaliActivity extends BaseActivity { } public void startContenutoBancaleActivity(MtbColt item){ - Intent myIntent = ContenutoBancaleActivity.createIntent(this, item, mCanRecoverUl, mPrinterType, mReportName); + Intent myIntent = ContenutoBancaleActivity.createIntent(this, item, mCanRecoverUl.run(item), mPrinterType, mReportName); startActivityForResult(myIntent, PICK_UL_REQUEST); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java index 0fd5c744..ae9aa5dc 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java @@ -309,10 +309,10 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment, } @Override - public void onLUClienteRequired(RunnableArgs onComplete, Runnable onAbort) { - DialogAskCliente.makeBase(getActivity(), (status, result) -> { + public void onLUClienteRequired(RunnableArgss onComplete, Runnable onAbort) { + DialogAskCliente.makeBase(getActivity(), (status, result, codJcom) -> { if (status == DialogConsts.Results.YES) { - onComplete.run(result); + onComplete.run(result, codJcom); } else { onAbort.run(); } @@ -401,7 +401,8 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment, @Override public void onPreDestroy(Runnable onComplete) { - if(thereIsAnOpenedUL.get()) mViewModel.closeLU(onComplete); BarcodeManager.removeCallback(barcodeScannerIstanceID); + if(thereIsAnOpenedUL.get()) mViewModel.closeLU(onComplete); + else onComplete.run(); } } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java index a00103cc..b4eb4c77 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java @@ -6,9 +6,7 @@ import com.annimon.stream.Stream; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; @@ -181,15 +179,15 @@ public class PickingLiberoViewModel { public void createNewLU(Integer customNumCollo, String customSerCollo, Runnable onComplete) { if (this.mFlagAskCliente) { - this.sendLUClienteRequired(vtbDest -> { - createNewLU_PostClienteAsk(customNumCollo, customSerCollo, vtbDest, onComplete); + this.sendLUClienteRequired((vtbDest, codJcom) -> { + createNewLU_PostClienteAsk(customNumCollo, customSerCollo, vtbDest, codJcom, onComplete); }, onComplete); } else { - createNewLU_PostClienteAsk(customNumCollo, customSerCollo, null, onComplete); + createNewLU_PostClienteAsk(customNumCollo, customSerCollo, null, null, onComplete); } } - private void createNewLU_PostClienteAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, Runnable onComplete) { + private void createNewLU_PostClienteAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, String codJcom, Runnable onComplete) { MtbColt mtbColt = new MtbColt(); mtbColt.initDefaultFields(); mtbColt.setGestione(mDefaultGestione) @@ -211,6 +209,10 @@ public class PickingLiberoViewModel { mtbColt.setCodVdes(vtbDest.getCodVdes()); } + if(!UtilityString.isNullOrEmpty(codJcom)) { + mtbColt.setCodJcom(codJcom); + } + mColliMagazzinoRESTConsumer.saveCollo(mtbColt, value -> { mtbColt .setNumCollo(value.getNumCollo()) @@ -233,9 +235,9 @@ public class PickingLiberoViewModel { BigDecimal qtaColDaPrelevare = null; BigDecimal qtaCnfDaPrelevare = null; - BigDecimal initialNumCnf = null; - BigDecimal initialQtaCnf = null; - BigDecimal initialQtaTot = null; + BigDecimal initialNumCnf; + BigDecimal initialQtaCnf; + BigDecimal initialQtaTot; String partitaMag = null; Date dataScad = null; @@ -758,7 +760,7 @@ public class PickingLiberoViewModel { if (this.mListener != null) mListener.onMtbColrDeleteRequest(onComplete); } - private void sendLUClienteRequired(RunnableArgs onComplete, Runnable onAbort) { + private void sendLUClienteRequired(RunnableArgss onComplete, Runnable onAbort) { if (this.mListener != null) mListener.onLUClienteRequired(onComplete, onAbort); } @@ -816,7 +818,7 @@ public class PickingLiberoViewModel { void onError(Exception ex); - void onLUClienteRequired(RunnableArgs onComplete, Runnable onAbort); + void onLUClienteRequired(RunnableArgss onComplete, Runnable onAbort); void onArtSelectionRequest(List mtbColrsToPick, RunnableArgs> onComplete, Runnable onAbort); diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/viewmodel/ProdRecuperoMaterialeViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/viewmodel/ProdRecuperoMaterialeViewModel.java index adf77b5d..bcd4d044 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/viewmodel/ProdRecuperoMaterialeViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/viewmodel/ProdRecuperoMaterialeViewModel.java @@ -1,12 +1,11 @@ package it.integry.integrywmsnative.gest.prod_recupero_materiale.viewmodel; -import android.app.Activity; import android.app.Dialog; -import android.content.Context; import android.text.SpannableString; import androidx.databinding.ObservableArrayList; import androidx.databinding.ObservableField; +import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.LinearLayoutManager; import com.annimon.stream.Stream; @@ -18,6 +17,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import it.integry.barcode_base_android_library.model.BarcodeScanDTO; import it.integry.integrywmsnative.R; import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO; import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager; @@ -31,6 +31,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsume import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.utility.UtilityBarcode; +import it.integry.integrywmsnative.core.utility.UtilityBigDecimal; import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityExceptions; import it.integry.integrywmsnative.core.utility.UtilityProgress; @@ -39,15 +40,16 @@ import it.integry.integrywmsnative.databinding.FragmentProdRecuperoMaterialeBind import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.HistoryULsListAdapter; import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.ProdRecuperoMaterialeHelper; import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO; +import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO; import it.integry.integrywmsnative.view.dialogs.DialogCommon; import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper; -import it.integry.integrywmsnative.view.dialogs.input_quantity.DialogInputQuantity; +import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2; +import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2DTO; import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCreateLU; -import it.integry.barcode_base_android_library.model.BarcodeScanDTO; public class ProdRecuperoMaterialeViewModel { - private Context mContext; + private FragmentActivity mContext; private FragmentProdRecuperoMaterialeBinding mBinding; private ProdRecuperoMaterialeHelper mHelper; @@ -61,7 +63,7 @@ public class ProdRecuperoMaterialeViewModel { private int barcodeScannerIstanceID = -1; - public void init(Activity context, FragmentProdRecuperoMaterialeBinding binding, ProdRecuperoMaterialeHelper helper, Runnable onRecuperoCompleted) { + public void init(FragmentActivity context, FragmentProdRecuperoMaterialeBinding binding, ProdRecuperoMaterialeHelper helper, Runnable onRecuperoCompleted) { mContext = context; mBinding = binding; mHelper = helper; @@ -152,32 +154,72 @@ public class ProdRecuperoMaterialeViewModel { } +// private void dispatchItem(HistoryVersamentoProdULDTO item, MtbColt sourceMtbColt, Dialog dialogProgress) { +// BigDecimal qtaDaEvadere = BigDecimal.ZERO; +// +// qtaDaEvadere = qtaDaEvadere.add(item.getQtaCol()); +// +// +// DialogInputQuantity.DTO dto = new DialogInputQuantity.DTO() +// .setBatchLot(item.getPartitaMag()) +// .setQtaDaEvadere(null) +// .setQtaOrd(null) +// .setMtbAart(item.getMtbAart()) +// .setCanPartitaMagBeChanged(false) +// .setNumCnf(1) +// .setQtaCnf(item.getQtaCnf()) +// .setQtaTot(item.getQtaCnf()) +// .setMaxQta(qtaDaEvadere) +// .setQtaDisponibile(qtaDaEvadere); +// +// DialogInputQuantity.makeBase(mContext, dto, false, quantity -> { +// onItemDispatched(item, quantity.qtaTot.getBigDecimal(), sourceMtbColt, dialogProgress); +// }, () -> { +// if (dialogProgress != null) dialogProgress.dismiss(); +// }).show(); +// } + + private void dispatchItem(HistoryVersamentoProdULDTO item, MtbColt sourceMtbColt, Dialog dialogProgress) { BigDecimal qtaDaEvadere = BigDecimal.ZERO; + BigDecimal numCnfDaEvadere = BigDecimal.ZERO; qtaDaEvadere = qtaDaEvadere.add(item.getQtaCol()); + if(!UtilityBigDecimal.equalsTo(qtaDaEvadere, BigDecimal.ZERO)) { + numCnfDaEvadere = UtilityBigDecimal.divide(qtaDaEvadere, item.getQtaCnf()); + } - DialogInputQuantity.DTO dto = new DialogInputQuantity.DTO() - .setBatchLot(item.getPartitaMag()) - .setQtaDaEvadere(null) - .setQtaOrd(null) + DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO() .setMtbAart(item.getMtbAart()) - .setCanPartitaMagBeChanged(false) - .setNumCnf(1) - .setQtaCnf(item.getQtaCnf()) - .setQtaTot(item.getQtaCnf()) - .setMaxQta(qtaDaEvadere) - .setQtaDisponibile(qtaDaEvadere); + .setInitialNumCnf(BigDecimal.ONE) + .setInitialQtaCnf(item.getQtaCnf()) + .setInitialQtaTot(item.getQtaCnf()) - DialogInputQuantity.makeBase(mContext, dto, false, quantity -> { - onItemDispatched(item, quantity.qtaTot.getBigDecimal(), sourceMtbColt, dialogProgress); - }, () -> { - if (dialogProgress != null) dialogProgress.dismiss(); - }).show(); + .setTotalQtaAvailable(qtaDaEvadere) + .setTotalNumCnfAvailable(numCnfDaEvadere) + .setQtaCnfAvailable(item.getQtaCnf()) + .setPartitaMag(item.getPartitaMag()) +// .setDataScad(item.getDa) + .setCanOverflowOrderQuantity(false) + .setCanLUBeClosed(false); + + DialogInputQuantityV2 + .newInstance(dialogInputQuantityV2DTO, (resultDTO, shouldCloseLU) -> { + PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO() + .setNumCnf(resultDTO.getNumCnf()) + .setQtaCnf(resultDTO.getQtaCnf()) + .setQtaTot(resultDTO.getQtaTot()) + .setPartitaMag(resultDTO.getPartitaMag()) + .setDataScad(resultDTO.getDataScad()); + + onItemDispatched(item, resultDTO.getQtaTot(), sourceMtbColt, dialogProgress); + }, () -> { + if (dialogProgress != null) dialogProgress.dismiss(); + }) + .show(mContext.getSupportFragmentManager(), "tag"); } - private void onItemDispatched(HistoryVersamentoProdULDTO item, BigDecimal quantity, MtbColt sourceMtbColt, Dialog progress) { if (progress == null) { diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java index 9d67afd5..ef2f7c3d 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java @@ -1,7 +1,5 @@ package it.integry.integrywmsnative.gest.rettifica_giacenze; -import androidx.databinding.ObservableArrayList; - import com.annimon.stream.Stream; import java.math.BigDecimal; @@ -27,12 +25,12 @@ import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbCols; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; +import it.integry.integrywmsnative.core.model.dto.PickDataDTO; import it.integry.integrywmsnative.core.report.ReportManager; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; -import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.utility.UtilityBarcode; import it.integry.integrywmsnative.core.utility.UtilityBigDecimal; import it.integry.integrywmsnative.core.utility.UtilityDate; @@ -40,7 +38,6 @@ import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.gest.rettifica_giacenze.core.RettificaGiacenzeRESTConsumer; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO; import it.integry.integrywmsnative.gest.spedizione.exceptions.InvalidPesoKGException; -import it.integry.integrywmsnative.core.model.dto.PickDataDTO; import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO; import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO; @@ -329,7 +326,7 @@ public class RettificaGiacenzeViewModel { mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE); - if (!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { +// if (!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { mtbColr .setQtaCol(BigDecimal.ZERO) .setNumCnf(BigDecimal.ZERO) @@ -359,39 +356,39 @@ public class RettificaGiacenzeViewModel { if (shouldCloseLU) closeLU(true, null); }, this::sendError); - } else { - mtbColr - .setQtaCol(qtaTot) - .setQtaCnf(qtaCnf) - .setNumCnf(numCnf); - - MtbColt cloneMtbColt = (MtbColt) mCurrentMtbColt.clone(); - cloneMtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP); - - cloneMtbColt.setMtbColr(new ObservableArrayList<>()); - - cloneMtbColt.getMtbColr().add(mtbColr); - - mColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, value -> { - mtbColr - .setDataCollo(value.getDataColloS()) - .setNumCollo(value.getNumCollo()) - .setGestione(value.getGestione()) - .setSerCollo(value.getSerCollo()) - .setRiga(value.getMtbColr().get(0).getRiga()) - .setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) - .setMtbAart(pickingObjectDTO.getMtbAart()); - - mCurrentMtbColt.getMtbColr().add(mtbColr); - - this.mAnyEditDone = true; - - this.sendOnRowSaved(); - this.sendOnLoadingEnded(); - - if (shouldCloseLU) closeLU(true, null); - }, this::sendError); - } +// } else { +// mtbColr +// .setQtaCol(qtaTot) +// .setQtaCnf(qtaCnf) +// .setNumCnf(numCnf); +// +// MtbColt cloneMtbColt = (MtbColt) mCurrentMtbColt.clone(); +// cloneMtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP); +// +// cloneMtbColt.setMtbColr(new ObservableArrayList<>()); +// +// cloneMtbColt.getMtbColr().add(mtbColr); +// +// mColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, value -> { +// mtbColr +// .setDataCollo(value.getDataColloS()) +// .setNumCollo(value.getNumCollo()) +// .setGestione(value.getGestione()) +// .setSerCollo(value.getSerCollo()) +// .setRiga(value.getMtbColr().get(0).getRiga()) +// .setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) +// .setMtbAart(pickingObjectDTO.getMtbAart()); +// +// mCurrentMtbColt.getMtbColr().add(mtbColr); +// +// this.mAnyEditDone = true; +// +// this.sendOnRowSaved(); +// this.sendOnLoadingEnded(); +// +// if (shouldCloseLU) closeLU(true, null); +// }, this::sendError); +// } } @@ -556,7 +553,7 @@ public class RettificaGiacenzeViewModel { private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, Date dataScad, boolean shouldCloseLU) { this.sendOnLoadingStarted(); - if(!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { +// if(!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { this.mColliMagazzinoRESTConsumer.creaRettificaCollo( mtbColrToUpdate, @@ -579,46 +576,46 @@ public class RettificaGiacenzeViewModel { this::sendError ); - } else { - - MtbColt mtbColt = new MtbColt() - .setNumCollo(mtbColrToUpdate.getNumCollo()) - .setDataCollo(mtbColrToUpdate.getDataColloS()) - .setSerCollo(mtbColrToUpdate.getSerCollo()) - .setGestione(mtbColrToUpdate.getGestione()) - .setMtbColr(new ObservableArrayList<>()); - mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP); - - final MtbColr mtbColr = (MtbColr) mtbColrToUpdate.clone(); - mtbColr - .setNumCnf(numCnf.subtract(mtbColr.getNumCnf())) - .setQtaCnf(qtaCnf) - .setQtaCol(qtaTot.subtract(mtbColr.getQtaCol())) - .setPartitaMag(partitaMag) - .setDataScadPartita(dataScad) - .setUtente(SettingsManager.i().getUser().getFullname()) - .setCausale(MtbColr.Causale.RETTIFICA) - .setDatetimeRow(UtilityDate.getDateInstance()) - .setOperation(CommonModelConsts.OPERATION.INSERT); - - mtbColt.getMtbColr().add(mtbColr); - - this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> { - - mtbColr.setNumCnf(numCnf) - .setQtaCnf(qtaCnf) - .setQtaCol(qtaTot); - - this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); - this.mCurrentMtbColt.getMtbColr().add(mtbColr); - - this.mAnyEditDone = true; - - this.sendOnRowSaved(); - this.sendOnLoadingEnded(); - - }, this::sendError); - } +// } else { +// +// MtbColt mtbColt = new MtbColt() +// .setNumCollo(mtbColrToUpdate.getNumCollo()) +// .setDataCollo(mtbColrToUpdate.getDataColloS()) +// .setSerCollo(mtbColrToUpdate.getSerCollo()) +// .setGestione(mtbColrToUpdate.getGestione()) +// .setMtbColr(new ObservableArrayList<>()); +// mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP); +// +// final MtbColr mtbColr = (MtbColr) mtbColrToUpdate.clone(); +// mtbColr +// .setNumCnf(numCnf.subtract(mtbColr.getNumCnf())) +// .setQtaCnf(qtaCnf) +// .setQtaCol(qtaTot.subtract(mtbColr.getQtaCol())) +// .setPartitaMag(partitaMag) +// .setDataScadPartita(dataScad) +// .setUtente(SettingsManager.i().getUser().getFullname()) +// .setCausale(MtbColr.Causale.RETTIFICA) +// .setDatetimeRow(UtilityDate.getDateInstance()) +// .setOperation(CommonModelConsts.OPERATION.INSERT); +// +// mtbColt.getMtbColr().add(mtbColr); +// +// this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> { +// +// mtbColr.setNumCnf(numCnf) +// .setQtaCnf(qtaCnf) +// .setQtaCol(qtaTot); +// +// this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); +// this.mCurrentMtbColt.getMtbColr().add(mtbColr); +// +// this.mAnyEditDone = true; +// +// this.sendOnRowSaved(); +// this.sendOnLoadingEnded(); +// +// }, this::sendError); +// } } public void deleteRow(MtbColr mtbColrToDelete) { @@ -626,7 +623,7 @@ public class RettificaGiacenzeViewModel { if (shouldDelete) { this.sendOnLoadingStarted(); - if(!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { +// if(!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { this.mColliMagazzinoRESTConsumer.creaRettificaCollo( mtbColrToDelete, BigDecimal.ZERO, @@ -638,37 +635,37 @@ public class RettificaGiacenzeViewModel { }, this::sendError ); - } else { - MtbColt mtbColt = new MtbColt() - .setNumCollo(mtbColrToDelete.getNumCollo()) - .setDataCollo(mtbColrToDelete.getDataColloS()) - .setSerCollo(mtbColrToDelete.getSerCollo()) - .setGestione(mtbColrToDelete.getGestione()) - .setMtbColr(new ObservableArrayList<>()); - mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP); - - MtbColr mtbColr = (MtbColr) mtbColrToDelete.clone(); - mtbColr - .setNumCnf(mtbColr.getNumCnf().multiply(new BigDecimal(-1))) - .setQtaCnf(mtbColr.getQtaCnf()) - .setQtaCol(mtbColr.getQtaCol().multiply(new BigDecimal(-1))) - .setPartitaMag(mtbColr.getPartitaMag()) - .setDataScadPartita(mtbColr.getDataScadPartitaD()) - .setUtente(SettingsManager.i().getUser().getFullname()) - .setCausale(MtbColr.Causale.RETTIFICA) - .setDatetimeRow(UtilityDate.getDateInstance()) - .setOperation(CommonModelConsts.OPERATION.INSERT); - - mtbColt.getMtbColr().add(mtbColr); - - this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> { - this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); - - this.sendOnRowSaved(); - this.sendOnLoadingEnded(); - - }, this::sendError); - } +// } else { +// MtbColt mtbColt = new MtbColt() +// .setNumCollo(mtbColrToDelete.getNumCollo()) +// .setDataCollo(mtbColrToDelete.getDataColloS()) +// .setSerCollo(mtbColrToDelete.getSerCollo()) +// .setGestione(mtbColrToDelete.getGestione()) +// .setMtbColr(new ObservableArrayList<>()); +// mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP); +// +// MtbColr mtbColr = (MtbColr) mtbColrToDelete.clone(); +// mtbColr +// .setNumCnf(mtbColr.getNumCnf().multiply(new BigDecimal(-1))) +// .setQtaCnf(mtbColr.getQtaCnf()) +// .setQtaCol(mtbColr.getQtaCol().multiply(new BigDecimal(-1))) +// .setPartitaMag(mtbColr.getPartitaMag()) +// .setDataScadPartita(mtbColr.getDataScadPartitaD()) +// .setUtente(SettingsManager.i().getUser().getFullname()) +// .setCausale(MtbColr.Causale.RETTIFICA) +// .setDatetimeRow(UtilityDate.getDateInstance()) +// .setOperation(CommonModelConsts.OPERATION.INSERT); +// +// mtbColt.getMtbColr().add(mtbColr); +// +// this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> { +// this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); +// +// this.sendOnRowSaved(); +// this.sendOnLoadingEnded(); +// +// }, this::sendError); +// } } }); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/viewmodel/VersamentoMerceViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/viewmodel/VersamentoMerceViewModel.java index c327d6e1..a455b69d 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/viewmodel/VersamentoMerceViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/versamento_merce/viewmodel/VersamentoMerceViewModel.java @@ -137,6 +137,10 @@ public class VersamentoMerceViewModel { UtilityExceptions.defaultException(mContext, ex, progressDialog); BarcodeManager.enable(); }); + } else { + progressDialog.dismiss(); + BarcodeManager.enable(); + showTooMuchULFound(); } }, ex -> { @@ -148,6 +152,12 @@ public class VersamentoMerceViewModel { } } + private void showTooMuchULFound() { + DialogSimpleMessageHelper.makeWarningDialog(mContext, + new SpannableString(mContext.getResources().getText(R.string.too_much_lu_found_message_in_mono_lu)), + null, null).show(); + } + private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO, Dialog progressDialog) { BarcodeRESTConsumer.decodeEan128Static(barcodeScanDTO, ean128Model -> { diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogAskLivelloPosizione.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogAskLivelloPosizione.java index a9e9b0d9..b2aae41d 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogAskLivelloPosizione.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/DialogAskLivelloPosizione.java @@ -16,6 +16,7 @@ import com.google.android.material.textfield.TextInputLayout; import it.integry.integrywmsnative.R; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; +import it.integry.integrywmsnative.core.utility.UtilityDialog; import it.integry.integrywmsnative.core.utility.UtilityFocus; import it.integry.integrywmsnative.core.utility.UtilityPosizione; @@ -55,6 +56,8 @@ public class DialogAskLivelloPosizione { mDialog.setCancelable(false); mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + UtilityDialog.setTo90PercentWidth(mContext, mDialog); + mDialog.setOnDismissListener(dialog -> { if(!completedFLow) onComplete.run(null); }); diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/DialogAskCliente.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/DialogAskCliente.java index 1f73f013..35fd8140 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/DialogAskCliente.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/DialogAskCliente.java @@ -15,7 +15,7 @@ import java.util.List; import java.util.Map; import it.integry.integrywmsnative.R; -import it.integry.integrywmsnative.core.expansion.RunnableArgss; +import it.integry.integrywmsnative.core.expansion.RunnableArgsss; import it.integry.integrywmsnative.core.model.VtbDest; import it.integry.integrywmsnative.core.utility.UtilityDialog; import it.integry.integrywmsnative.databinding.DialogAskClienteBinding; @@ -32,11 +32,11 @@ public class DialogAskCliente { private DialogAskClienteBinding mBinding; - public static Dialog makeBase(final Context context, RunnableArgss onComplete) { + public static Dialog makeBase(final Context context, RunnableArgsss onComplete) { return new DialogAskCliente(context, onComplete).mDialog; } - public DialogAskCliente(Context context, RunnableArgss onComplete) { + public DialogAskCliente(Context context, RunnableArgsss onComplete) { mContext = context; @@ -72,25 +72,24 @@ public class DialogAskCliente { viewModel1 .setOnConfirmClickListener(() -> { - - viewModel2.setCodAnag(viewModel1.getCurrentCliente().getCodAnag()); + viewModel2.setCodAnag(viewModel1.getCurrentCliente()); mBinding.viewpager.setCurrentItem(mBinding.viewpager.getCurrentItem() + 1, true); }); viewModel1.setOnAbortClickListener(() -> { mDialog.dismiss(); - onComplete.run(DialogConsts.Results.ABORT, null); + onComplete.run(DialogConsts.Results.ABORT, null, null); }); viewModel2.setOnConfirmClickListener(() -> { - onComplete.run(DialogConsts.Results.YES, viewModel2.getCurrentDestinatario().toVtbDestModel()); + onComplete.run(DialogConsts.Results.YES, viewModel2.getCurrentDestinatario().toVtbDestModel(), viewModel1.getCurrentCommessa()); mDialog.dismiss(); }); viewModel2.setOnAbortClickListener(() -> { mDialog.dismiss(); - onComplete.run(DialogConsts.Results.ABORT, null); + onComplete.run(DialogConsts.Results.ABORT, null, null); }); }); diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/dto/DialogAskClienteClienteDTO.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/dto/DialogAskClienteClienteDTO.java index 4bbbe8d2..ce2c0242 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/dto/DialogAskClienteClienteDTO.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/dto/DialogAskClienteClienteDTO.java @@ -1,10 +1,12 @@ package it.integry.integrywmsnative.view.dialogs.ask_cliente.dto; +import java.util.ArrayList; + public class DialogAskClienteClienteDTO { private String codAnag; - private String ragSoc; + private ArrayList codJcoms = new ArrayList<>(); public String getCodAnag() { return codAnag; @@ -24,6 +26,14 @@ public class DialogAskClienteClienteDTO { return this; } + public ArrayList getCodJcoms() { + return codJcoms; + } + + public DialogAskClienteClienteDTO setCodJcoms(ArrayList codJcoms) { + this.codJcoms = codJcoms; + return this; + } @Override public String toString() { diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1ViewModel.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1ViewModel.java index 62624f50..2966a253 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1ViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1ViewModel.java @@ -2,18 +2,32 @@ package it.integry.integrywmsnative.view.dialogs.ask_cliente.viewmodel; import android.content.Context; import android.widget.AutoCompleteTextView; +import android.widget.Toast; +import androidx.databinding.ObservableArrayList; +import androidx.databinding.ObservableList; import androidx.databinding.ViewDataBinding; +import com.annimon.stream.Optional; +import com.annimon.stream.Stream; import com.google.gson.reflect.TypeToken; +import com.tfb.fbtoast.FBToast; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import it.integry.barcode_base_android_library.model.BarcodeScanDTO; import it.integry.integrywmsnative.R; +import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO; +import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager; +import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback; +import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; +import it.integry.integrywmsnative.core.utility.UtilityExceptions; +import it.integry.integrywmsnative.core.utility.UtilityHashMap; import it.integry.integrywmsnative.databinding.DialogAskClientePage1Binding; import it.integry.integrywmsnative.view.dialogs.ask_cliente.dto.DialogAskClienteClienteDTO; @@ -22,7 +36,10 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod private Context mContext; private DialogAskClientePage1Binding mBinding; - private List availableClienti; + private int mBarcodeScannerInstanceID; + + private ArrayList availableClienti; + private ObservableArrayList codJcoms = new ObservableArrayList<>(); public DialogAskCliente_Page1ViewModel() { @@ -41,18 +58,43 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod @Override public void onShow() { - String sql = "SELECT gtb_anag.cod_anag, rag_soc " + + String sql = "SELECT gtb_anag.cod_anag, rag_soc, jtb_comt.cod_jcom " + "FROM gtb_anag " + + "LEFT OUTER JOIN jtb_comt ON gtb_anag.cod_anag = jtb_comt.cod_anag " + "INNER JOIN vtb_clie ON gtb_anag.cod_anag = vtb_clie.cod_anag " + "WHERE vtb_clie.flag_stato = 'A' " + "ORDER BY rag_soc"; - Type typeOfObjectsList = new TypeToken>() {}.getType(); - SystemRESTConsumer.processSqlStatic(sql, typeOfObjectsList, new ISimpleOperationCallback>() { + Type typeOfObjectsList = new TypeToken>>() { + }.getType(); + SystemRESTConsumer.processSqlStatic(sql, typeOfObjectsList, new ISimpleOperationCallback>>() { @Override - public void onSuccess(ArrayList value) { - availableClienti = value; - initializeAdapter(value); + public void onSuccess(ArrayList> value) { + + availableClienti = new ArrayList<>(); + + Stream.of(value) + .groupBy(x -> x.get("codAnag").toString() + " " + x.get("ragSoc").toString()) + .forEach(x -> { + DialogAskClienteClienteDTO dialogAskClienteClienteDTO = new DialogAskClienteClienteDTO(); + dialogAskClienteClienteDTO.setCodAnag(UtilityHashMap.getValueIfExists(x.getValue().get(0), "codAnag")); + dialogAskClienteClienteDTO.setRagSoc(UtilityHashMap.getValueIfExists(x.getValue().get(0), "ragSoc")); + + for (HashMap group : x.getValue()) { + if (group.containsKey("codJcom")) { + dialogAskClienteClienteDTO.getCodJcoms().add(UtilityHashMap.getValueIfExists(group, "codJcom")); + } + } + + availableClienti.add(dialogAskClienteClienteDTO); + }); + + initializeAdapter(availableClienti); + + mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO() + .setOnScanSuccessfull(onScanSuccessful) + .setOnScanFailed(ex -> UtilityExceptions.defaultException(mContext, ex, false))); + BarcodeManager.enable(); } @Override @@ -66,9 +108,10 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod @Override public void setOnConfirmClickListener(Runnable onConfirm) { this.mBinding.buttonYes.setOnClickListener(v -> { - if(validateCliente()) { + if (validateCliente()) { this.resetClienteError(); - if(onConfirm != null) onConfirm.run(); + BarcodeManager.removeCallback(mBarcodeScannerInstanceID); + if (onConfirm != null) onConfirm.run(); } else { this.setClienteError(mContext.getResources().getText(R.string.not_valid_customer_error).toString()); } @@ -76,22 +119,90 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod }); } + + private final RunnableArgs onScanSuccessful = data -> { + BarcodeManager.disable(); + + String barcode = data.getStringValue(); + + DialogAskClienteClienteDTO resultCodAnag = searchBarcodeInCodAnag(barcode); + + if (resultCodAnag != null) { + mBinding.dropdownCliente.setText(resultCodAnag.toString()); + refreshCodJcoms(resultCodAnag); + } else { + DialogAskClienteClienteDTO resultCodJcom = searchBarcodeInCodJcom(barcode); + + if(resultCodJcom != null) { + mBinding.dropdownCliente.setText(resultCodJcom.toString()); + refreshCodJcoms(resultCodJcom); + mBinding.dropdownCommessa.setText(barcode); + } else { + FBToast.errorToast(mContext, "Nessun risultato trovato", Toast.LENGTH_LONG); + mBinding.dropdownCliente.setText(""); + mBinding.dropdownCommessa.setText(""); + } + } + + BarcodeManager.enable(); + }; + + + private DialogAskClienteClienteDTO searchBarcodeInCodAnag(String barcode) { + List resultCodAnag = Stream.of(availableClienti) + .filter(x -> barcode.equalsIgnoreCase(x.getCodAnag())) + .toList(); + if (resultCodAnag.size() > 0) { + return resultCodAnag.get(0); + } else return null; + } + + private DialogAskClienteClienteDTO searchBarcodeInCodJcom(String barcode) { + List resultCodJcom = Stream.of(availableClienti) + .filter(x -> x.getCodJcoms().contains(barcode)) + .toList(); + if (resultCodJcom.size() > 0) { + return resultCodJcom.get(0); + } else return null; + } + @Override public void setOnAbortClickListener(Runnable onAbort) { this.mBinding.buttonNo.setOnClickListener(v -> { - if(onAbort != null) onAbort.run(); + if (onAbort != null) onAbort.run(); }); } private void initializeAdapter(ArrayList items) { + DialogAskCliente_Page1_Cliente_ArrayAdapter adapter = new DialogAskCliente_Page1_Cliente_ArrayAdapter(mContext, items); - DialogAskCliente_Page1_ArrayAdapter adapter = new DialogAskCliente_Page1_ArrayAdapter(mContext, items); + AutoCompleteTextView editTextDropdownCliente = mBinding.dropdownCliente; + editTextDropdownCliente.setThreshold(0); + editTextDropdownCliente.setAdapter(adapter); + editTextDropdownCliente.setOnItemClickListener((parent, view, position, id) -> { + refreshCodJcoms(items.get(position)); + }); - AutoCompleteTextView editTextFilledExposedDropdown = mBinding.filledExposedDropdown; - editTextFilledExposedDropdown.setThreshold(0); - editTextFilledExposedDropdown.setAdapter(adapter); + DialogAskCliente_Page1_Commessa_ArrayAdapter commessaAdapter = new DialogAskCliente_Page1_Commessa_ArrayAdapter(mContext); + + AutoCompleteTextView editTextDropdownCommessa = mBinding.dropdownCommessa; + editTextDropdownCommessa.setThreshold(0); + editTextDropdownCommessa.setAdapter(commessaAdapter); + + codJcoms.addOnListChangedCallback(new OnListGeneralChangedCallback() { + @Override + public void onChanged(ObservableList sender) { + commessaAdapter.clear(); + commessaAdapter.addAll(codJcoms); + } + }); + } + + private void refreshCodJcoms(DialogAskClienteClienteDTO item) { + codJcoms.clear(); + codJcoms.addAll(item.getCodJcoms()); } @@ -99,22 +210,34 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod return getCurrentCliente() != null; } - public DialogAskClienteClienteDTO getCurrentCliente() { - for (DialogAskClienteClienteDTO cliente : availableClienti) { - if(cliente.getRagSoc().equalsIgnoreCase(mBinding.inputCliente.getEditText().getText().toString())) { - return cliente; - } - } + public String getCurrentCliente() { + Optional result = Stream.of(availableClienti) + .filter(x -> x.getRagSoc().equalsIgnoreCase(mBinding.inputCliente.getEditText().getText().toString())) + .findFirst(); - return null; + if(result.isPresent()) return result.get().getCodAnag(); + else return null; + } + + public String getCurrentCommessa() { + String codAnag = getCurrentCliente(); + Optional> result = Stream.of(availableClienti) + .filter(x -> x.getCodAnag().equalsIgnoreCase(codAnag)) + .map(DialogAskClienteClienteDTO::getCodJcoms) + .findFirst(); + + if(result.isPresent() && Stream.of(result.get()).anyMatch(x -> x.equalsIgnoreCase(mBinding.inputCommessa.getEditText().getText().toString()))) { + return mBinding.inputCommessa.getEditText().getText().toString(); + } else return null; } - private void setClienteError(String message){ + private void setClienteError(String message) { mBinding.inputCliente.setErrorEnabled(true); mBinding.inputCliente.setError(message); mBinding.inputCliente.setErrorIconDrawable(null); } + private void resetClienteError() { mBinding.inputCliente.setError(null); } diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1_ArrayAdapter.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1_Cliente_ArrayAdapter.java similarity index 91% rename from app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1_ArrayAdapter.java rename to app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1_Cliente_ArrayAdapter.java index f591466d..9d900cf5 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1_ArrayAdapter.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page1_Cliente_ArrayAdapter.java @@ -1,7 +1,6 @@ package it.integry.integrywmsnative.view.dialogs.ask_cliente.viewmodel; import android.content.Context; -import android.graphics.Movie; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -9,7 +8,6 @@ import android.widget.ArrayAdapter; import android.widget.Filter; import android.widget.Filterable; -import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; @@ -20,7 +18,7 @@ import java.util.List; import it.integry.integrywmsnative.R; import it.integry.integrywmsnative.view.dialogs.ask_cliente.dto.DialogAskClienteClienteDTO; -public class DialogAskCliente_Page1_ArrayAdapter extends ArrayAdapter implements Filterable { +public class DialogAskCliente_Page1_Cliente_ArrayAdapter extends ArrayAdapter implements Filterable { private Context mContext; private List mDataset; @@ -28,7 +26,7 @@ public class DialogAskCliente_Page1_ArrayAdapter extends ArrayAdapter list) { + public DialogAskCliente_Page1_Cliente_ArrayAdapter(@NonNull Context context, @NonNull ArrayList list) { super(context, 0 , list); mContext = context; mDataset = list; @@ -43,13 +41,13 @@ public class DialogAskCliente_Page1_ArrayAdapter extends ArrayAdapter implements Filterable { + + private Context mContext; + private List mDataset = new ArrayList<>(); + private List mDatasetAllItems; + + private DialogAskCliente_Page1_Commessa_ArrayAdapter.ListFilter listFilter = new DialogAskCliente_Page1_Commessa_ArrayAdapter.ListFilter(); + + public DialogAskCliente_Page1_Commessa_ArrayAdapter(@NonNull Context context) { + super(context, 0); + mContext = context; + + + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + View listItem = convertView; + if(listItem == null) { + listItem = LayoutInflater.from(mContext).inflate(R.layout.dialog_ask_cliente__dropdown_item, parent, false); + } + + if(position < getCount()) { + AppCompatTextView textView = listItem.findViewById(R.id.text); + textView.setText(getItem(position)); + return listItem; + } + return convertView; + } + + + @NonNull + @Override + public Filter getFilter() { + return listFilter; + } + + public class ListFilter extends Filter { + private Object lock = new Object(); + + @Override + protected FilterResults performFiltering(CharSequence prefix) { + FilterResults results = new FilterResults(); + if (mDatasetAllItems == null) { + synchronized (lock) { + mDatasetAllItems = new ArrayList<>(mDataset); + } + } + + if (prefix == null || prefix.length() == 0) { + synchronized (lock) { + results.values = mDatasetAllItems; + results.count = mDatasetAllItems.size(); + } + } else { + final String searchStrLowerCase = prefix.toString().toLowerCase(); + + ArrayList matchValues = new ArrayList<>(); + + for (String dataItem : mDatasetAllItems) { + if (dataItem.toLowerCase().startsWith(searchStrLowerCase)) { + matchValues.add(dataItem); + } + } + + results.values = matchValues; + results.count = matchValues.size(); + } + + return results; + } + + @Override + protected void publishResults(CharSequence constraint, FilterResults results) { + if (results.values != null) { + mDataset.clear(); + mDataset.addAll((ArrayList) results.values); + } else { + mDataset.clear(); + } + if (results.count > 0) { + notifyDataSetChanged(); + } else { + notifyDataSetInvalidated(); + } + } + + } + +} diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page2ViewModel.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page2ViewModel.java index 191b9f98..7c86bf78 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page2ViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/ask_cliente/viewmodel/DialogAskCliente_Page2ViewModel.java @@ -44,12 +44,12 @@ public class DialogAskCliente_Page2ViewModel implements IDialogAskClienteViewMod @Override public void onShow() { - String sql = "SELECT cod_anag, cod_vdes, destinatario, indirizzo, cap, citta, prov, nazione " + "FROM vtb_dest " + "WHERE cod_anag = " + UtilityDB.valueToString(mCodAnag); - Type typeOfObjectsList = new TypeToken>() {}.getType(); + Type typeOfObjectsList = new TypeToken>() { + }.getType(); SystemRESTConsumer.processSqlStatic(sql, typeOfObjectsList, new ISimpleOperationCallback>() { @Override public void onSuccess(ArrayList value) { @@ -67,9 +67,9 @@ public class DialogAskCliente_Page2ViewModel implements IDialogAskClienteViewMod @Override public void setOnConfirmClickListener(Runnable onConfirm) { this.mBinding.buttonYes.setOnClickListener(v -> { - if(validateDestinatario()) { + if (validateDestinatario()) { this.resetClienteError(); - if(onConfirm != null) onConfirm.run(); + if (onConfirm != null) onConfirm.run(); } else { this.setClienteError(mContext.getResources().getText(R.string.not_valid_recipient_error).toString()); } @@ -80,7 +80,7 @@ public class DialogAskCliente_Page2ViewModel implements IDialogAskClienteViewMod @Override public void setOnAbortClickListener(Runnable onAbort) { this.mBinding.buttonNo.setOnClickListener(v -> { - if(onAbort != null) onAbort.run(); + if (onAbort != null) onAbort.run(); }); } @@ -88,12 +88,13 @@ public class DialogAskCliente_Page2ViewModel implements IDialogAskClienteViewMod this.mCodAnag = codAnag; } + private void initializeAdapter(ArrayList items) { DialogAskCliente_Page2_ArrayAdapter adapter = new DialogAskCliente_Page2_ArrayAdapter(mContext, items); - AutoCompleteTextView editTextFilledExposedDropdown = mBinding.filledExposedDropdown; + AutoCompleteTextView editTextFilledExposedDropdown = mBinding.dropdownDestinatario; editTextFilledExposedDropdown.setThreshold(0); editTextFilledExposedDropdown.setAdapter(adapter); } @@ -105,7 +106,7 @@ public class DialogAskCliente_Page2ViewModel implements IDialogAskClienteViewMod public DialogAskClienteDestinatarioDTO getCurrentDestinatario() { for (DialogAskClienteDestinatarioDTO destinatarioDTO : availableDestinatari) { - if(destinatarioDTO.toString().equalsIgnoreCase(mBinding.inputDestinatario.getEditText().getText().toString())) { + if (destinatarioDTO.toString().equalsIgnoreCase(mBinding.inputDestinatario.getEditText().getText().toString())) { return destinatarioDTO; } } @@ -114,11 +115,12 @@ public class DialogAskCliente_Page2ViewModel implements IDialogAskClienteViewMod } - private void setClienteError(String message){ + private void setClienteError(String message) { mBinding.inputDestinatario.setErrorEnabled(true); mBinding.inputDestinatario.setError(message); mBinding.inputDestinatario.setErrorIconDrawable(null); } + private void resetClienteError() { mBinding.inputDestinatario.setError(null); } diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/DialogInputQuantity.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/DialogInputQuantity.java deleted file mode 100644 index 88560468..00000000 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/DialogInputQuantity.java +++ /dev/null @@ -1,755 +0,0 @@ -package it.integry.integrywmsnative.view.dialogs.input_quantity; - -import android.app.DatePickerDialog; -import android.app.Dialog; -import android.content.Context; -import android.content.res.ColorStateList; - -import androidx.databinding.DataBindingUtil; -import androidx.databinding.Observable; - -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.os.Handler; -import com.google.android.material.textfield.TextInputLayout; -import androidx.core.content.ContextCompat; -import androidx.appcompat.widget.AppCompatTextView; -import android.text.Html; -import android.text.SpannableString; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; - -import org.jetbrains.annotations.NotNull; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -import it.integry.integrywmsnative.R; -import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; -import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel; -import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO; -import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager; -import it.integry.integrywmsnative.core.expansion.RunnableArgs; -import it.integry.integrywmsnative.core.expansion.RunnableArgss; -import it.integry.integrywmsnative.core.model.MtbAart; -import it.integry.integrywmsnative.core.utility.UtilityBarcode; -import it.integry.integrywmsnative.core.utility.UtilityDate; -import it.integry.integrywmsnative.core.utility.UtilityExceptions; -import it.integry.integrywmsnative.core.utility.UtilityLogger; -import it.integry.integrywmsnative.core.utility.UtilityNumber; -import it.integry.integrywmsnative.core.utility.UtilityProgress; -import it.integry.integrywmsnative.core.utility.UtilityString; -import it.integry.integrywmsnative.databinding.DialogInputQuantityArticoloBinding; -import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper; -import it.integry.barcode_base_android_library.model.BarcodeScanDTO; - -public class DialogInputQuantity { - - public static class DTO { - private MtbAart mtbAart; - private String batchLot; - private BigDecimal qtaDaEvadere; - private BigDecimal qtaDisponibile; - private BigDecimal qtaEvasa; - private BigDecimal qtaOrd; - private BigDecimal qtaTot; - private BigDecimal qtaCnf; - private Integer numCnf; - private BigDecimal maxQta; - private String codArtFor; - private Date dataScad; - private boolean canPartitaMagBeChanged; - private Boolean canDataScadBeChanged; - private Boolean shouldAskDataScad; - - public MtbAart getMtbAart() { - return mtbAart; - } - - public DTO setMtbAart(MtbAart mtbAart) { - this.mtbAart = mtbAart; - return this; - } - - public String getBatchLot() { - return batchLot; - } - - public DTO setBatchLot(String batchLot) { - this.batchLot = batchLot; - return this; - } - - public BigDecimal getQtaDaEvadere() { - return qtaDaEvadere; - } - - public DTO setQtaDaEvadere(BigDecimal qtaDaEvadere) { - this.qtaDaEvadere = qtaDaEvadere; - return this; - } - - public BigDecimal getQtaDisponibile() { - return qtaDisponibile; - } - - public DTO setQtaDisponibile(BigDecimal qtaDisponibile) { - this.qtaDisponibile = qtaDisponibile; - return this; - } - - public BigDecimal getQtaOrd() { - return qtaOrd; - } - - public DTO setQtaOrd(BigDecimal qtaOrd) { - this.qtaOrd = qtaOrd; - return this; - } - - public BigDecimal getQtaTot() { - return qtaTot; - } - - public DTO setQtaTot(BigDecimal qtaTot) { - this.qtaTot = qtaTot; - return this; - } - - public BigDecimal getQtaCnf() { - return qtaCnf; - } - - public DTO setQtaCnf(BigDecimal qtaCnf) { - this.qtaCnf = qtaCnf; - return this; - } - - public Integer getNumCnf() { - return numCnf; - } - - public DTO setNumCnf(Integer numCnf) { - this.numCnf = numCnf; - return this; - } - - public BigDecimal getQtaEvasa() { - return qtaEvasa; - } - - public DTO setQtaEvasa(BigDecimal qtaEvasa) { - this.qtaEvasa = qtaEvasa; - return this; - } - - public BigDecimal getMaxQta() { - return maxQta; - } - - public DTO setMaxQta(BigDecimal maxQta) { - this.maxQta = maxQta; - return this; - } - - public String getCodArtFor() { - return codArtFor; - } - - public DTO setCodArtFor(String codArtFor) { - this.codArtFor = codArtFor; - return this; - } - - public Date getDataScad() { - return dataScad; - } - - public DTO setDataScad(Date dataScad) { - this.dataScad = dataScad; - return this; - } - - public boolean getCanPartitaMagBeChanged() { - return canPartitaMagBeChanged; - } - - public DTO setCanPartitaMagBeChanged(boolean canPartitaMagBeChanged) { - this.canPartitaMagBeChanged = canPartitaMagBeChanged; - return this; - } - - public Boolean isCanDataScadBeChanged() { - return canDataScadBeChanged; - } - - public DTO setCanDataScadBeChanged(boolean canDataScadBeChanged) { - this.canDataScadBeChanged = canDataScadBeChanged; - return this; - } - - public Boolean getShouldAskDataScad() { - return shouldAskDataScad; - } - - public DTO setShouldAskDataScad(Boolean shouldAskDataScad) { - this.shouldAskDataScad = shouldAskDataScad; - return this; - } - } - - private ColorStateList originalColorStateList = null; - - private String scadenzaString = "Scadenza"; - - private Dialog currentDialog; - private Context currentContext; - - private DialogInputQuantityArticoloBinding currentBinding; - - private MtbAart currentMtbAart; - private QuantityDTO currentQuantityDto; - private DTO currentDTO; - - public static Dialog makeBase(final Context context, final DTO dto, boolean canOverflowQuantity, final RunnableArgs dialogCallback, final Runnable onAbort) { - return new DialogInputQuantity(context, dto, canOverflowQuantity, false, (quantityDto, closeUL) -> { - dialogCallback.run(quantityDto); - }, onAbort).currentDialog; - } - - public static Dialog makeBase(final Context context, final DTO dto, boolean canOverflowQuantity, final RunnableArgss dialogCallback, final Runnable onAbort) { - return new DialogInputQuantity(context, dto, canOverflowQuantity, true, dialogCallback, onAbort).currentDialog; - } - - public DialogInputQuantity(@NotNull Context context, @NotNull final DTO dto, boolean canOverflowQuantity, boolean showCloseUL, final RunnableArgss dialogCallback, final Runnable onAbort) { - currentContext = context; - currentMtbAart = dto.getMtbAart(); - currentDTO = dto; - - LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); - currentBinding = DataBindingUtil.inflate(inflater, R.layout.dialog_input_quantity_articolo, null, false); - - final TextInputLayout txlInputBatchLot = currentBinding.inputPartitaMag; - - final TextInputLayout txlInputNumDiCnf = currentBinding.inputNumCnf; - final TextInputLayout txlInputQtaPerCnf = currentBinding.inputQtaCnf; - final TextInputLayout txlInputQtaTot = currentBinding.inputQtaTot; - - txlInputNumDiCnf.getEditText().setSelectAllOnFocus(true); - txlInputQtaPerCnf.getEditText().setSelectAllOnFocus(true); - txlInputQtaTot.getEditText().setSelectAllOnFocus(true); - - - originalColorStateList = txlInputNumDiCnf.getEditText().getTextColors(); - - currentQuantityDto = new QuantityDTO(); - currentQuantityDto.canOverflowQuantity = canOverflowQuantity; - - setupQuantities(dto, currentQuantityDto); - - setupQuantityListener(currentQuantityDto, txlInputNumDiCnf, txlInputQtaPerCnf, txlInputQtaTot); - - currentBinding.setViewmodel(dto); - currentBinding.setQuantityViewModel(currentQuantityDto); - - - currentDialog = new Dialog(context); - currentDialog.setContentView(currentBinding.getRoot()); - - currentDialog.setCanceledOnTouchOutside(false); - currentDialog.setCancelable(false); - currentDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); - - currentDialog.setCanceledOnTouchOutside(false); - - currentDialog.setOnShowListener(dialogInterface -> { - - final Handler handler = new Handler(); - handler.postDelayed(() -> { - EditText editTextToFocus; - if(currentQuantityDto.canPartitaMagBeChanged.get()) { - editTextToFocus = txlInputBatchLot.getEditText(); - } else { - editTextToFocus = txlInputNumDiCnf.getEditText(); - } - - - editTextToFocus.requestFocus(); - - InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(editTextToFocus, InputMethodManager.SHOW_IMPLICIT); - - }, 100); - - }); - - currentBinding.saveBtn.setOnClickListener(view -> { - onConfirm(context, currentQuantityDto, dialogCallback, false); - currentDialog.dismiss(); - }); - currentBinding.abortBtn.setOnClickListener(view -> { - if(onAbort != null) onAbort.run(); - currentDialog.dismiss(); - }); - - currentBinding.closeLuBtn.setVisibility(showCloseUL ? View.VISIBLE : View.INVISIBLE); - currentBinding.closeLuBtn.setOnClickListener(view -> { - onConfirm(context, currentQuantityDto, dialogCallback, true); - currentDialog.dismiss(); - }); - - initDatePicker(context, currentQuantityDto, currentBinding.getRoot().findViewById(R.id.input_data_scad)); - - setupBarcode(context); - } - - private void setupQuantities(@NotNull DTO dto, QuantityDTO quantityDTO){ - if(dto.getQtaTot() != null) quantityDTO.qtaTot.set(dto.getQtaTot().floatValue()); - if(dto.getMaxQta() != null) quantityDTO.maxQta.set(dto.getMaxQta().floatValue()); - - float qtaDisponibile = dto.getQtaDisponibile() != null ? dto.getQtaDisponibile().floatValue() : 0f; - if (qtaDisponibile < 0) { - currentBinding.layoutQtaDisponibile.setVisibility(View.GONE); - qtaDisponibile = 0; - } - if(qtaDisponibile > 0) quantityDTO.qtaDisponibile.set(qtaDisponibile); - - float qtaDaEvadere = dto.qtaDaEvadere != null ? dto.qtaDaEvadere.floatValue() : 0f; - if (qtaDaEvadere < 0) { - currentBinding.layoutQtaDaEvadere.setVisibility(View.GONE); - qtaDaEvadere = 0; - } - - if(qtaDaEvadere > 0) quantityDTO.qtaDaEvadere.set(qtaDaEvadere); - quantityDTO.qtaEvasa.set(dto.qtaEvasa != null ? dto.qtaEvasa.floatValue() : null); - - quantityDTO.batchLot.set(dto.batchLot); - if(quantityDTO.qtaCnf.get(false) == null) { - if(dto.getQtaCnf() != null) { - - quantityDTO.qtaCnf.set(dto.getQtaCnf().floatValue()); - - } else if(dto.numCnf != null && dto.qtaTot != null && - dto.numCnf > 0 && dto.qtaTot.compareTo(BigDecimal.ZERO) > 0) { - - quantityDTO.qtaCnfNotificationEnabled = false; - quantityDTO.qtaCnf.set(dto.qtaTot.divide(new BigDecimal(dto.numCnf), RoundingMode.HALF_EVEN).floatValue()); - quantityDTO.qtaCnfNotificationEnabled = true; - - } else { - - quantityDTO.qtaCnf.set(dto.mtbAart.getQtaCnf().floatValue()); - - if(dto.getMtbAart().isFlagQtaCnfFissaBoolean()) { - quantityDTO.blockedQtaPerCnf.set(true); - } - } - } - - if(quantityDTO.qtaTot.get(false) == null) { - quantityDTO.qtaTot.set(qtaDaEvadere); - } - - if(dto.getNumCnf() != null) { - quantityDTO.numCnf.set(new BigDecimal(dto.getNumCnf()).floatValue()); - } - - if(quantityDTO.numCnf.get(false) == null) { - float numCnf = (float) Math.ceil(UtilityNumber.truncateToDecimal(quantityDTO.qtaTot.get() / quantityDTO.qtaCnf.get(),3)); - if(numCnf < 1) numCnf = 1; - quantityDTO.numCnf.set(numCnf); - } - - quantityDTO.canPartitaMagBeChanged.set(dto.getCanPartitaMagBeChanged()); - - if(dto.isCanDataScadBeChanged() != null){ - quantityDTO.canDataScadBeChanged.set(dto.isCanDataScadBeChanged()); - } - - quantityDTO.shouldAskDataScad.set(dto.mtbAart.isFlagTracciabilitaBoolean() && dto.mtbAart.getGgScadPartita() != null && dto.mtbAart.getGgScadPartita() > 0); - - if(dto.getShouldAskDataScad() != null) { - quantityDTO.shouldAskDataScad.set(dto.getShouldAskDataScad()); - } - - if(dto.getDataScad() != null) { - quantityDTO.expireDate = dto.getDataScad(); - } - - if(quantityDTO.expireDate == null && dto.mtbAart.getGgScadPartita() != null && dto.mtbAart.getGgScadPartita() > 0) { - Calendar c = UtilityDate.getCalendarInstance(); - c.add(Calendar.DATE, dto.mtbAart.getGgScadPartita()); // number of days to add - - quantityDTO.expireDate = c.getTime(); - } - - refreshQtaDescriptionText(); - - } - - - private void setupBarcode(Context context) { - - int barcodeIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO() - .setOnScanSuccessfull(onScanSuccessfull) - .setOnScanFailed(ex -> UtilityExceptions.defaultException(context, ex, false))); - - currentDialog.setOnDismissListener(dialog -> { - BarcodeManager.removeCallback(barcodeIstanceID); - }); - - BarcodeManager.enable(); - - } - - - private final RunnableArgs onScanSuccessfull = data -> { - BarcodeManager.disable(); - - if(UtilityBarcode.isEanPeso(data)){ - - try { - Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(data.getStringValue()); - - if(ean13PesoModel.getPrecode().contains(currentMtbAart.getBarCode())) { - - currentQuantityDto.numCnf.set(1f); - currentQuantityDto.qtaCnf.set(ean13PesoModel.getPeso()); - currentQuantityDto.qtaTot.set(ean13PesoModel.getPeso()); - - BarcodeManager.enable(); - } else { - BarcodeManager.enable(); - } - - } catch (Exception e) { - UtilityLogger.errorMe(e); - BarcodeManager.enable(); - } - - } else if(UtilityBarcode.isEtichetta128(data)){ - final Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(currentContext); - - BarcodeRESTConsumer.decodeEan128Static(data, ean128Model -> { - progressDialog.dismiss(); - BarcodeManager.enable(); - - if(ean128Model != null){ - if(!UtilityString.isNullOrEmpty(ean128Model.BatchLot)) { - currentQuantityDto.batchLot.set(ean128Model.BatchLot); - } - - try { - if(!UtilityString.isNullOrEmpty(ean128Model.BestBefore)){ - currentQuantityDto.expireDate = UtilityDate.recognizeDate(ean128Model.BestBefore); - } else if(!UtilityString.isNullOrEmpty(ean128Model.Expiry)) { - currentQuantityDto.expireDate = UtilityDate.recognizeDate(ean128Model.Expiry); - } - - if(currentQuantityDto.expireDate != null) { - currentQuantityDto.expireDateString.set(UtilityDate.formatDate(currentQuantityDto.expireDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)); - } - - } catch (Exception e) { - UtilityLogger.errorMe(e); - } - - - if(ean128Model.Count != null && ean128Model.Count > 0) { - currentQuantityDto.numCnf.set((float) ean128Model.Count); - } - - if (ean128Model.NetWeightKg != null && ean128Model.NetWeightKg > 0) { - currentQuantityDto.qtaTot.set(ean128Model.NetWeightKg); - } - - if(currentQuantityDto.qtaTot.get() > 0 && currentQuantityDto.numCnf.get() > 0) { - currentQuantityDto.qtaCnf.set(currentQuantityDto.qtaTot.get() / currentQuantityDto.numCnf.get()); - } - - } - - - }, ex -> { - UtilityExceptions.defaultException(currentContext, ex, progressDialog); - - BarcodeManager.enable(); - }); - - } else { - BarcodeManager.enable(); - } - - }; - - private void setupQuantityListener(final QuantityDTO quantityDTO, final TextInputLayout txlInputNumDiCnf, final TextInputLayout txlInputQtaPerCnf, final TextInputLayout txlInputQtaTot) { - - quantityDTO.numCnf.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { - @Override - public void onPropertyChanged(Observable sender, int propertyId) { - - if(quantityDTO.numCnfNotificationEnabled) { - - quantityDTO.blockedNumDiCnf.set(!(quantityDTO.numCnf.get(true) == 0 || quantityDTO.numCnf.get().toString().equals(""))); - - toggleTextInputLayoutError(txlInputNumDiCnf, quantityDTO.blockedNumDiCnf.get()); - - if (!quantityDTO.blockedQtaTot.get()) { - - quantityDTO.qtaTotNotificationEnabled = false; - quantityDTO.qtaTot.set((float) Math.round(quantityDTO.qtaCnf.get(true) * quantityDTO.numCnf.get(true) * 1000) / 1000); - quantityDTO.qtaTotNotificationEnabled = true; - - - } else if (!quantityDTO.blockedQtaPerCnf.get()) { - - quantityDTO.qtaCnfNotificationEnabled = false; - if(quantityDTO.numCnf.get(true) != 0) { - quantityDTO.qtaCnf.set((float) Math.round(quantityDTO.qtaTot.get(true) / quantityDTO.numCnf.get(true) * 1000) / 1000); - } else { - quantityDTO.qtaCnf.set((float) Math.round(quantityDTO.qtaTot.get(true) / 1 * 1000) / 1000); - } - quantityDTO.qtaCnfNotificationEnabled = true; - - } else { - Log.e("DialogInputQuantity", "Tutti i campi sono bloccati, non è possibile modificare il numero di confezioni"); - } - - } - -// refreshQtaDescriptionText(); - } - }); - - quantityDTO.qtaCnf.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { - @Override - public void onPropertyChanged(Observable sender, int propertyId) { - - if(quantityDTO.qtaCnfNotificationEnabled) { - - quantityDTO.blockedQtaPerCnf.set(!(quantityDTO.qtaCnf.get(true) == 0 || quantityDTO.qtaCnf.get().toString().equals(""))); - - toggleTextInputLayoutError(txlInputQtaPerCnf, quantityDTO.blockedQtaPerCnf.get()); - - if (!quantityDTO.blockedQtaTot.get()) { - - quantityDTO.qtaTotNotificationEnabled = false; - float qtaTot = (float) Math.round(quantityDTO.qtaCnf.get(true) * quantityDTO.numCnf.get(true) * 1000) / 1000; - if(qtaTot > quantityDTO.maxQta.get() && !quantityDTO.canOverflowQuantity) qtaTot = quantityDTO.maxQta.get(); - quantityDTO.qtaTot.set(qtaTot); - quantityDTO.qtaTotNotificationEnabled = true; - - } else if (!quantityDTO.blockedNumDiCnf.get()) { - - quantityDTO.numCnfNotificationEnabled = false; - if(quantityDTO.qtaCnf.get(true) != 0){ - quantityDTO.numCnf.set((float) Math.ceil(quantityDTO.qtaTot.get(true) / quantityDTO.qtaCnf.get(true))); - } else { - quantityDTO.numCnf.set((float) Math.ceil(quantityDTO.qtaTot.get(true))); - } - - quantityDTO.numCnfNotificationEnabled = true; - - } else { - Log.e("DialogInputQuantity", "Tutti i campi sono bloccati, non è possibile modificare la quantità per confezione"); - } - } - -// refreshQtaDescriptionText(); - } - }); - - quantityDTO.qtaTot.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { - @Override - public void onPropertyChanged(Observable sender, int propertyId) { - - if (quantityDTO.qtaTotNotificationEnabled) { - - quantityDTO.blockedQtaTot.set(!(quantityDTO.qtaTot.get(true) == 0 || quantityDTO.qtaTot.get().toString().equals(""))); - - toggleTextInputLayoutError(txlInputQtaTot, quantityDTO.blockedQtaTot.get()); - - if(!quantityDTO.blockedQtaPerCnf.get()){ - - quantityDTO.qtaCnfNotificationEnabled = false; - quantityDTO.qtaCnf.set((float) Math.round(quantityDTO.qtaTot.get(true) / quantityDTO.numCnf.get(true) *1000)/1000); - quantityDTO.qtaCnfNotificationEnabled = true; - - } else if(!quantityDTO.blockedNumDiCnf.get()) { - - quantityDTO.numCnfNotificationEnabled = false; - quantityDTO.numCnf.set((float) Math.ceil(quantityDTO.qtaTot.get(true) / quantityDTO.qtaCnf.get(true))); - quantityDTO.numCnfNotificationEnabled = true; - - } else { - Log.e("DialogInputQuantity", "Tutti i campi sono bloccati, non è possibile modificare la quantità totale"); - } - - } - -// refreshQtaDescriptionText(); - } - }); - - } - - - private void toggleTextInputLayoutError(TextInputLayout textInputLayout, boolean isError) { - if(isError){ - textInputLayout.setErrorEnabled(true); - textInputLayout.setError(" "); - textInputLayout.getEditText().setTextColor(ContextCompat.getColor(currentContext, R.color.red_600)); - textInputLayout.setHintTextAppearance(R.style.ErrorFloatingLabel); - textInputLayout.setErrorIconDrawable(null); - - if (textInputLayout.getChildCount() == 2) { - textInputLayout.getChildAt(1).setVisibility(View.GONE); - } - } else { - textInputLayout.setErrorEnabled(false); - textInputLayout.setError(null); - textInputLayout.getEditText().setTextColor(originalColorStateList); - textInputLayout.setHintTextAppearance(R.style.NormalFloatingLabel); - } - } - - private void initDatePicker(Context context, QuantityDTO quantityDTO, AppCompatTextView textInputLayout) { - quantityDTO.expireDateString.set(scadenzaString); - - if(quantityDTO.expireDate != null) { - quantityDTO.expireDateString.set(UtilityDate.formatDate(quantityDTO.expireDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)); - } - - - Runnable onTextClicked = () -> { - // Get Current Date - Calendar c = UtilityDate.getCalendarInstance(); - - if(quantityDTO.expireDate != null) { - c.setTime(quantityDTO.expireDate); - } - - int mYear = c.get(Calendar.YEAR); - int mMonth = c.get(Calendar.MONTH); - int mDay = c.get(Calendar.DAY_OF_MONTH); - - DatePickerDialog datePickerDialog = new DatePickerDialog(context, - (view, year, month, day) -> { - - quantityDTO.expireDate = new GregorianCalendar(year, month, day).getTime(); - quantityDTO.expireDateString.set(UtilityDate.formatDate(quantityDTO.expireDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)); - - }, mYear, mMonth, mDay); - datePickerDialog.show(); - }; - - textInputLayout.setOnClickListener(v -> onTextClicked.run()); - - - } - - - private void refreshQtaDescriptionText() { - - int numConf = (int) (currentQuantityDto.qtaDaEvadere.get() / currentQuantityDto.qtaCnf.get()); - float qtaTot = currentQuantityDto.qtaDaEvadere.get(); - - float mod = qtaTot % numConf; - - String text = ""; - - if(numConf > 0) { - text += "" + numConf + " " + currentContext.getResources().getQuantityString(R.plurals.item_package, numConf).toUpperCase() + ""; - } - if(numConf > 0 && mod > 0) { - text += " e "; - } - if(mod > 0) { - - text += "" + UtilityNumber.decimalToString(mod) + " "; - if(mod == 1) { - text += currentContext.getResources().getQuantityString(R.plurals.pieces, (int) mod).toUpperCase(); - } else { - text += currentContext.getString(R.string.piece).toUpperCase(); - } - - text += ""; - } - - currentBinding.qtaDescriptionText.setText(Html.fromHtml(text)); - - } - - - - private void onConfirm(Context context, QuantityDTO quantityDTO, RunnableArgss dialogCallback, boolean closeUL){ - if(currentDTO.mtbAart.isFlagTracciabilitaBoolean() && (quantityDTO.batchLot == null || quantityDTO.batchLot.get().trim().length() == 0)){ - - showBatchLotErrorPrompt(context); - - } else if(quantityDTO.shouldAskDataScad.get() && (quantityDTO.batchLot == null || quantityDTO.batchLot.get().trim().length() == 0)){ - - showBatchLotErrorPrompt(context); - - } else if(quantityDTO.shouldAskDataScad.get() && quantityDTO.expireDate == null){ - - showExpireDateErrorPrompt(context); - - } else if(!quantityDTO.canOverflowQuantity && quantityDTO.qtaTot.get() > quantityDTO.maxQta.get()) { - - showQuantityOverflowErrorPrompt(context); - - } else if(quantityDTO.qtaCnf.get() <= 0 || quantityDTO.numCnf.get() <= 0 || quantityDTO.qtaTot.get() <= 0) { - - showQuantityErrorDialog(context); - - } else { - - if(quantityDTO.batchLot != null && !quantityDTO.batchLot.isEmpty()) { - quantityDTO.batchLot.set(quantityDTO.batchLot.get().toUpperCase()); - } - - dialogCallback.run(quantityDTO, closeUL); - currentDialog.dismiss(); - - } - } - - - private void showQuantityErrorDialog(Context mContext){ - - String errorMessage = mContext.getText(R.string.wrong_quantity_input_message).toString(); - - DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show(); - } - - - private void showQuantityOverflowErrorPrompt(Context mContext){ - - String errorMessage = mContext.getText(R.string.available_quantity_overflow_error_message).toString(); - - DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show(); - } - - - private void showExpireDateErrorPrompt(Context mContext){ - - String errorMessage = mContext.getText(R.string.expire_date_error_message).toString(); - - DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show(); - } - - - private void showBatchLotErrorPrompt(Context mContext){ - - String errorMessage = mContext.getText(R.string.batch_lot_error_message).toString(); - DialogSimpleMessageHelper.makeErrorDialog(mContext, new SpannableString(Html.fromHtml(errorMessage)), null, null).show(); - } - -} diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/QuantityDTO.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/QuantityDTO.java deleted file mode 100644 index 39f92533..00000000 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/QuantityDTO.java +++ /dev/null @@ -1,42 +0,0 @@ -package it.integry.integrywmsnative.view.dialogs.input_quantity; - -import java.util.Date; - -import it.integry.integrywmsnative.core.di.BindableBoolean; -import it.integry.integrywmsnative.core.di.BindableFloat; -import it.integry.integrywmsnative.core.di.BindableString; - -public class QuantityDTO { - - public BindableString batchLot = new BindableString(); - public BindableString expireDateString = new BindableString(); - - public Date expireDate = null; - - public BindableFloat numCnf = new BindableFloat(); - public BindableFloat qtaCnf = new BindableFloat(); - public BindableFloat qtaTot = new BindableFloat(); - - public BindableFloat qtaEvasa = new BindableFloat(); - public BindableFloat qtaDaEvadere = new BindableFloat(); - public BindableFloat qtaDisponibile = new BindableFloat(); - - - - public BindableBoolean blockedNumDiCnf = new BindableBoolean(); - public BindableBoolean blockedQtaTot = new BindableBoolean(); - public BindableBoolean blockedQtaPerCnf = new BindableBoolean(); - - public boolean numCnfNotificationEnabled = true; - public boolean qtaCnfNotificationEnabled = true; - public boolean qtaTotNotificationEnabled = true; - public boolean canOverflowQuantity = false; - public BindableFloat maxQta = new BindableFloat(); - - - public BindableBoolean canPartitaMagBeChanged = new BindableBoolean(true); - public BindableBoolean canDataScadBeChanged = new BindableBoolean(true); - public BindableBoolean shouldAskDataScad = new BindableBoolean(); - - -} diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLU.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLU.java index 192f2bf2..2d2f7c67 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLU.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/scan_or_create_lu/DialogScanOrCreateLU.java @@ -288,7 +288,7 @@ public class DialogScanOrCreateLU { private void showTooMuchULFound() { DialogSimpleMessageHelper.makeWarningDialog(mContext, - new SpannableString(mContext.getResources().getText(R.string.too_much_lu_found_message)), + new SpannableString(mContext.getResources().getText(R.string.too_much_lu_found_message_in_mono_lu)), null, null).show(); } diff --git a/app/src/main/res/layout/activity_accettazione_ordine_inevaso.xml b/app/src/main/res/layout/activity_accettazione_ordine_inevaso.xml index 6b9086bd..108e3ee8 100644 --- a/app/src/main/res/layout/activity_accettazione_ordine_inevaso.xml +++ b/app/src/main/res/layout/activity_accettazione_ordine_inevaso.xml @@ -124,7 +124,7 @@ + android:clipToPadding="false" + android:paddingBottom="72dp"/> @@ -186,7 +187,7 @@ - + diff --git a/app/src/main/res/layout/dialog_ask_cliente__page1.xml b/app/src/main/res/layout/dialog_ask_cliente__page1.xml index ab8ba6cc..169cf0d5 100644 --- a/app/src/main/res/layout/dialog_ask_cliente__page1.xml +++ b/app/src/main/res/layout/dialog_ask_cliente__page1.xml @@ -34,9 +34,10 @@ android:layout_marginTop="16dp" android:layout_marginBottom="8dp" /> - + android:layout_height="wrap_content" + android:orientation="vertical"> - + + + + + + + diff --git a/app/src/main/res/layout/dialog_ask_cliente__page2.xml b/app/src/main/res/layout/dialog_ask_cliente__page2.xml index 27cbab39..e16c4c6a 100644 --- a/app/src/main/res/layout/dialog_ask_cliente__page2.xml +++ b/app/src/main/res/layout/dialog_ask_cliente__page2.xml @@ -46,7 +46,7 @@ android:hint="@string/recipient"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 0b74f2bb..89088874 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -200,6 +200,7 @@ Numero ordine Commessa Cliente + Commessa Destinatario Data consegna Data documento @@ -217,7 +218,7 @@ Sono ammesse solo UL di Acquisto o Lavorazione qui Acquisto o Vendita non sono ammesse qui]]> Vendita non sono ammesse qui]]> - E\' stata trovata più di una UL + E\' stata trovata più di una UL in una posizione MONO-UL Scansiona il codice a barre di una Posizione Scansiona il codice a barre di una Linea di Produzione diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 20f583ed..48f7e3a7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -203,6 +203,7 @@ Orders number Orders job Customer + Job Recipient Ship date Document date @@ -220,7 +221,7 @@ Only Purchase or Production\'s LU are accepted here The LU of type Purchase or Sale is not accepted here The LU of type Sale is not accepted here - Multiple LU found + Multiple LU found in MONO-LU position Do you want print the label? Please scan a Position barcode Please scan a Production Line barcode