Completata gestione della nuova Rettifica Giacenze

This commit is contained in:
Giuseppe Scorrano 2020-05-14 10:05:44 +02:00
parent cff91c86fb
commit c6adc453f6

View File

@ -423,48 +423,74 @@ public class RettificaGiacenzeViewModel implements IRecyclerItemClicked<MtbColr>
.setCodMart(mtbAart.getCodMart())
.setPartitaMag(quantityDTO.batchLot.get())
.setDataScadPartita(quantityDTO.expireDate)
.setQtaCol(quantityDTO.qtaTot.getBigDecimal())
.setNumCnf(quantityDTO.numCnf.getBigDecimal())
.setDescrizione(mtbAart.getDescrizioneEstesa())
.setCausale(MtbColr.Causale.RETTIFICA)
.setUtente(SettingsManager.i().user.fullname);
mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
MtbColt cloneMtbColt = (MtbColt) mtbColt.get().clone();
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
if (!isCreatedLU) {
mtbColr
.setQtaCol(BigDecimal.ZERO)
.setNumCnf(BigDecimal.ZERO)
.setDataCollo(mtbColt.get().getDataColloS())
.setNumCollo(mtbColt.get().getNumCollo())
.setGestione(mtbColt.get().getGestione())
.setSerCollo(mtbColt.get().getSerCollo());
cloneMtbColt.setMtbColr(new ObservableArrayList());
cloneMtbColt.getMtbColr().add(mtbColr);
ColliMagazzinoRESTConsumer.creaRettificaCollo(mtbColr,
quantityDTO.numCnf.getBigDecimal(),
quantityDTO.qtaTot.getBigDecimal(),
() -> {
mtbColr.setUntMis(mtbAart.getUntMis())
.setMtbAart(mtbAart);
// ColliMagazzinoRESTConsumer.creaRettificaCollo(mtbColr);
mtbColt.get().getMtbColr().add(mtbColr);
FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
ColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, new ISimpleOperationCallback<MtbColt>() {
@Override
public void onSuccess(MtbColt value) {
resetTexts();
progress.dismiss();
}, ex -> {
UtilityExceptions.defaultException(mContext, ex, progress);
});
} else {
mtbColr
.setQtaCol(quantityDTO.qtaTot.getBigDecimal())
.setNumCnf(quantityDTO.numCnf.getBigDecimal());
mtbColr
.setDataCollo(value.getDataColloS())
.setNumCollo(value.getNumCollo())
.setGestione(value.getGestione())
.setSerCollo(value.getSerCollo())
.setRiga(value.getMtbColr().get(0).getRiga())
.setUntMis(mtbAart.getUntMis())
.setMtbAart(mtbAart);
MtbColt cloneMtbColt = (MtbColt) mtbColt.get().clone();
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
mtbColt.get().getMtbColr().add(mtbColr);
cloneMtbColt.setMtbColr(new ObservableArrayList());
cloneMtbColt.getMtbColr().add(mtbColr);
FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
ColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, new ISimpleOperationCallback<MtbColt>() {
@Override
public void onSuccess(MtbColt value) {
resetTexts();
progress.dismiss();
}
mtbColr
.setDataCollo(value.getDataColloS())
.setNumCollo(value.getNumCollo())
.setGestione(value.getGestione())
.setSerCollo(value.getSerCollo())
.setRiga(value.getMtbColr().get(0).getRiga())
.setUntMis(mtbAart.getUntMis())
.setMtbAart(mtbAart);
@Override
public void onFailed(Exception ex) {
UtilityExceptions.defaultException(mContext, ex, progress);
}
});
mtbColt.get().getMtbColr().add(mtbColr);
FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
resetTexts();
progress.dismiss();
}
@Override
public void onFailed(Exception ex) {
UtilityExceptions.defaultException(mContext, ex, progress);
}
});
}
}
@ -636,7 +662,7 @@ public class RettificaGiacenzeViewModel implements IRecyclerItemClicked<MtbColr>
.setRiga(null);
if(!isCreatedLU) {
if (!isCreatedLU) {
BigDecimal finalNewNumCnf = newNumCnf;
ColliMagazzinoRESTConsumer.creaRettificaCollo(
mtbColrToEditClone,
@ -711,7 +737,7 @@ public class RettificaGiacenzeViewModel implements IRecyclerItemClicked<MtbColr>
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
if(!isCreatedLU) {
if (!isCreatedLU) {
ColliMagazzinoRESTConsumer.creaRettificaCollo(
mtbColrToDeleteClone,
BigDecimal.ZERO,