Finish RemoveSetupCheckFornitore
This commit is contained in:
commit
49782755bc
@ -178,6 +178,6 @@ public class DocInterniFragment extends BaseFragment implements ITitledFragment,
|
||||
@Override
|
||||
public void onDocumentEditRequest(SqlMtbColt document, List<DocumentoArtDTO> arts) {
|
||||
requireActivity()
|
||||
.startActivity(DocInterniEditFormActivity.newInstance(requireActivity(), document, arts, mViewModel.getTipoDoc()));
|
||||
.startActivity(DocInterniEditFormActivity.newInstance(requireActivity(), document, arts, mViewModel.getTipoDoc(), mDocInterniSetupDTO));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
package it.integry.integrywmsnative.gest.contab_doc_interni.dto;
|
||||
|
||||
public class CheckFornitoreDTO {
|
||||
|
||||
private String codDtip;
|
||||
private Boolean flagCheckPartitaMag;
|
||||
|
||||
public String getCodDtip() {
|
||||
return codDtip;
|
||||
}
|
||||
|
||||
public CheckFornitoreDTO setCodDtip(String codDtip) {
|
||||
this.codDtip = codDtip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlagCheckPartitaMag() {
|
||||
return flagCheckPartitaMag;
|
||||
}
|
||||
|
||||
public CheckFornitoreDTO setFlagCheckPartitaMag(Boolean flagCheckPartitaMag) {
|
||||
this.flagCheckPartitaMag = flagCheckPartitaMag;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package it.integry.integrywmsnative.gest.contab_doc_interni.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FornitoreDTO {
|
||||
|
||||
|
||||
@ -13,6 +15,8 @@ public class FornitoreDTO {
|
||||
|
||||
private String gestioneAnag;
|
||||
|
||||
private List<CheckFornitoreDTO> checkFornitoreDTO;
|
||||
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
@ -57,4 +61,13 @@ public class FornitoreDTO {
|
||||
public String getLabel() {
|
||||
return this.codAnag + (this.codVdes != null ? " - "+ this.codVdes : "") +" ( " + this.descrizione+" )";
|
||||
}
|
||||
|
||||
public List<CheckFornitoreDTO> getCheckFornitoreDTO() {
|
||||
return checkFornitoreDTO;
|
||||
}
|
||||
|
||||
public FornitoreDTO setCheckFornitoreDTO(List<CheckFornitoreDTO> checkFornitoreDTO) {
|
||||
this.checkFornitoreDTO = checkFornitoreDTO;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ public class TipoDocDTO {
|
||||
private String descrizione;
|
||||
private String gestione;
|
||||
private String gestioneDoc;
|
||||
private boolean flagChkTracciabilita;
|
||||
private boolean requireNote = false;
|
||||
|
||||
public String getCodDtip() {
|
||||
@ -52,4 +53,13 @@ public class TipoDocDTO {
|
||||
this.requireNote = requireNote;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagChkTracciabilita() {
|
||||
return flagChkTracciabilita;
|
||||
}
|
||||
|
||||
public TipoDocDTO setFlagChkTracciabilita(boolean flagChkTracciabilita) {
|
||||
this.flagChkTracciabilita = flagChkTracciabilita;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ import it.integry.integrywmsnative.core.model.MtbUntMis;
|
||||
import it.integry.integrywmsnative.core.rest.model.documento.DocumentoArtDTO;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.databinding.ActivityContabDocInterniEditBinding;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipoDocDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.dialog.selectDocRows.DialogSelectDocRowsItemListModel;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.dialog.selectDocRows.DialogSelectDocRowsView;
|
||||
@ -55,6 +56,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
||||
private static final String DATA_KEY_DOCUMENT = "document";
|
||||
private static final String DATA_KEY_PRODUCTS_LIST = "productsList";
|
||||
private static final String DATA_KEY_TIPO_DOC = "docType";
|
||||
private static final String DATA_KEY_DOC_INTERNI = "docInterniSetup";
|
||||
|
||||
@Inject
|
||||
MtbColrDataSource documentRowsRepository;
|
||||
@ -78,15 +80,18 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
||||
public BindableBoolean isDocumentExportable = new BindableBoolean(false);
|
||||
private final ObservableArrayList<SqlMtbColr> documentRowsObservableList = new ObservableArrayList<>();
|
||||
|
||||
public static Intent newInstance(Context context, SqlMtbColt document, List<DocumentoArtDTO> arts, TipoDocDTO tipoDoc) {
|
||||
public static Intent newInstance(Context context, SqlMtbColt document, List<DocumentoArtDTO> arts, TipoDocDTO tipoDoc, DocInterniSetupDTO mDocInterniSetupDTO) {
|
||||
Intent myIntent = new Intent(context, DocInterniEditFormActivity.class);
|
||||
|
||||
String doc = DataCache.addItem(document);
|
||||
String productsKey = DataCache.addItem(arts);
|
||||
String docType = DataCache.addItem(tipoDoc);
|
||||
String docInterniSetup = DataCache.addItem(mDocInterniSetupDTO);
|
||||
|
||||
myIntent.putExtra(DATA_KEY_DOCUMENT, doc);
|
||||
myIntent.putExtra(DATA_KEY_PRODUCTS_LIST, productsKey);
|
||||
myIntent.putExtra(DATA_KEY_TIPO_DOC, docType);
|
||||
myIntent.putExtra(DATA_KEY_DOC_INTERNI, docInterniSetup);
|
||||
return myIntent;
|
||||
}
|
||||
|
||||
@ -103,13 +108,14 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
||||
SqlMtbColt document = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_DOCUMENT));
|
||||
List<DocumentoArtDTO> productList = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_PRODUCTS_LIST));
|
||||
TipoDocDTO docType = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_TIPO_DOC));
|
||||
DocInterniSetupDTO docInterniSetupDTO = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_DOC_INTERNI));
|
||||
|
||||
this.initViewModel();
|
||||
this.viewModel.setDocInterniSetupDTO(docInterniSetupDTO);
|
||||
this.viewModel.setDocument(document);
|
||||
this.viewModel.setProductsList(productList);
|
||||
this.viewModel.setTipoDoc(docType);
|
||||
|
||||
|
||||
this.initView();
|
||||
this.initBindables();
|
||||
this.initRecyclerView();
|
||||
|
||||
@ -2,6 +2,7 @@ package it.integry.integrywmsnative.gest.contab_doc_interni.edit_form;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -10,6 +11,7 @@ import org.json.JSONObject;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -28,7 +30,10 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.ArtDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.CheckFornitoreDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.ColloDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.FornitoreDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipoDocDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
|
||||
@ -48,6 +53,7 @@ public class DocInterniEditFormViewModel {
|
||||
|
||||
|
||||
public MutableLiveData<SqlMtbColt> document = new MutableLiveData<>();
|
||||
public MutableLiveData<DocInterniSetupDTO> docInterniSetupDTO = new MutableLiveData<>();
|
||||
public MutableLiveData<List<SqlMtbColr>> docRows = new MutableLiveData<>();
|
||||
|
||||
@Inject
|
||||
@ -236,6 +242,7 @@ public class DocInterniEditFormViewModel {
|
||||
artDto.setColli(BigDecimal.valueOf(row.getNumCnf()));
|
||||
artDto.setUntMis(row.getUntMis());
|
||||
artDto.setCodMart(row.getCodMart());
|
||||
artDto.setSystemNote(row.getNote());
|
||||
if (row.getDataScad() != null) {
|
||||
artDto.setDataScad(row.getDataScad());
|
||||
}
|
||||
@ -257,35 +264,48 @@ public class DocInterniEditFormViewModel {
|
||||
this.initCheckFornitore();
|
||||
}
|
||||
|
||||
public void setDocInterniSetupDTO(DocInterniSetupDTO docInterniSetupDTO) {
|
||||
this.docInterniSetupDTO.setValue(docInterniSetupDTO);
|
||||
}
|
||||
|
||||
private void initCheckFornitore() {
|
||||
SqlMtbColt doc = this.document.getValue();
|
||||
List<FornitoreDTO> fornitori = Objects.requireNonNull(this.docInterniSetupDTO.getValue()).getFornitori();
|
||||
List<TipoDocDTO> tipoDocDTO = Objects.requireNonNull(this.docInterniSetupDTO.getValue()).getTipiDoc();
|
||||
this.isCheckPartitaMag = false;
|
||||
|
||||
if (doc == null)
|
||||
if (doc == null || fornitori == null || tipoDocDTO == null)
|
||||
return;
|
||||
|
||||
boolean isCheckPartitaMag = false;
|
||||
List<FornitoreDTO> filterFornitori = Stream.of(fornitori).filter(x->x.getCodAnag().equals(doc.getCodAnag())).toList();
|
||||
List<CheckFornitoreDTO> checkFornitoreDTO;
|
||||
|
||||
try {
|
||||
if (this.checkFornitoreRules != null && this.checkFornitoreRules.has("value")) {
|
||||
isCheckPartitaMag = this.checkFornitoreRules.getBoolean("value");
|
||||
} else if (this.checkFornitoreRules != null) {
|
||||
String key = doc.getCodAnag();
|
||||
if (doc.getCodVdes() != null && !doc.getCodVdes().isEmpty()) {
|
||||
key += "-" + doc.getCodVdes();
|
||||
}
|
||||
if (this.checkFornitoreRules.has(key) &&
|
||||
((String) ((JSONObject) this.checkFornitoreRules.get(key))
|
||||
.get(doc.getCodDtipProvv()))
|
||||
.equalsIgnoreCase("check-partitaMag")) {
|
||||
isCheckPartitaMag = true;
|
||||
}
|
||||
TipoDocDTO tipoDoc = Stream.of(tipoDocDTO).filter(x -> x.getCodDtip().equals(doc.getCodDtipProvv())).findFirst().get();
|
||||
|
||||
if (tipoDoc.isFlagChkTracciabilita()){
|
||||
this.isCheckPartitaMag = tipoDoc.isFlagChkTracciabilita();
|
||||
}else{
|
||||
if (filterFornitori.isEmpty())
|
||||
return;
|
||||
|
||||
if (doc.getCodVdes() == null) {
|
||||
checkFornitoreDTO = Stream.of(filterFornitori)
|
||||
.filter(x -> x.getCodVdes() == null).findFirst().get().getCheckFornitoreDTO();
|
||||
} else{
|
||||
checkFornitoreDTO = Stream.of(filterFornitori)
|
||||
.filter(x -> x.getCodVdes().equals(doc.getCodVdes())).findFirst().get().getCheckFornitoreDTO();
|
||||
}
|
||||
|
||||
if (checkFornitoreDTO != null){
|
||||
CheckFornitoreDTO flagCheck = Stream.of(checkFornitoreDTO)
|
||||
.filter(x -> x.getCodDtip().equals(doc.getCodDtipProvv())).findFirstOrElse(null);
|
||||
|
||||
if (flagCheck == null)
|
||||
return;
|
||||
|
||||
this.isCheckPartitaMag = flagCheck.getFlagCheckPartitaMag();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
this.sendError(e);
|
||||
}
|
||||
|
||||
|
||||
this.isCheckPartitaMag = isCheckPartitaMag;
|
||||
}
|
||||
|
||||
public SqlMtbColt getDocument() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user