Connection conn = null;
try {
if (this.conn==null) conn = getConn(); else conn = this.conn;
bean.setConn(conn);
VariantsMatrixColumnVO colVO = null;
VariantsMatrixRowVO rowVO = null;
MovementVO vo = null;
Response res = null;
int pos = 0;
ArrayList sn = new ArrayList();
for(int i=0;i<cells.length;i++) {
rowVO = (VariantsMatrixRowVO)matrixVO.getRowDescriptors()[i];
if (matrixVO.getColumnDescriptors().length==0) {
if (cells[i][0]!=null) {
vo = (MovementVO)voTemplate.clone();
if (!containsVariant(matrixVO,"ITM11_VARIANTS_1")) {
// e.g. color but not no size...
vo.setVariantCodeItm11WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm06WAR02(ApplicationConsts.JOLLY);
}
else {
vo.setVariantCodeItm11WAR02(rowVO.getVariantCodeITM11());
vo.setVariantTypeItm06WAR02(rowVO.getVariantTypeITM06());
}
if (!containsVariant(matrixVO,"ITM12_VARIANTS_2")) {
vo.setVariantCodeItm12WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm07WAR02(ApplicationConsts.JOLLY);
}
else {
vo.setVariantCodeItm12WAR02(rowVO.getVariantCodeITM11());
vo.setVariantTypeItm07WAR02(rowVO.getVariantTypeITM06());
}
if (!containsVariant(matrixVO,"ITM13_VARIANTS_3")) {
vo.setVariantCodeItm13WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm08WAR02(ApplicationConsts.JOLLY);
}
else {
vo.setVariantCodeItm13WAR02(rowVO.getVariantCodeITM11());
vo.setVariantTypeItm08WAR02(rowVO.getVariantTypeITM06());
}
if (!containsVariant(matrixVO,"ITM14_VARIANTS_4")) {
vo.setVariantCodeItm14WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm09WAR02(ApplicationConsts.JOLLY);
}
else {
vo.setVariantCodeItm14WAR02(rowVO.getVariantCodeITM11());
vo.setVariantTypeItm09WAR02(rowVO.getVariantTypeITM06());
}
if (!containsVariant(matrixVO,"ITM15_VARIANTS_5")) {
vo.setVariantCodeItm15WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm10WAR02(ApplicationConsts.JOLLY);
}
else {
vo.setVariantCodeItm15WAR02(rowVO.getVariantCodeITM11());
vo.setVariantTypeItm10WAR02(rowVO.getVariantTypeITM06());
}
//PurchaseUtils.updateTotals(vo,currencyDecimals.intValue());
/*
vo.setVariantCodeItm11WAR02(rowVO.getVariantCodeITM11());
vo.setVariantTypeItm06WAR02(rowVO.getVariantTypeITM06());
vo.setVariantCodeItm12WAR02(ApplicationConsts.JOLLY);
vo.setVariantCodeItm13WAR02(ApplicationConsts.JOLLY);
vo.setVariantCodeItm14WAR02(ApplicationConsts.JOLLY);
vo.setVariantCodeItm15WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm07WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm08WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm09WAR02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm10WAR02(ApplicationConsts.JOLLY);
*/
try {
vo.setDeltaQtyWAR02((BigDecimal)cells[i][0]);
} catch (Exception e) {
continue;
}
sn.clear();
if (vo.getDeltaQtyWAR02().intValue()>0) {
sn.addAll(voTemplate.getSerialNumbers().subList(pos,pos+vo.getDeltaQtyWAR02().intValue()));
}
vo.setSerialNumbers(sn);
pos += vo.getDeltaQtyWAR02().intValue();
}
WarehouseMovementVO movVO = new WarehouseMovementVO(
vo.getProgressiveHie01WAR02(),
vo.getDeltaQtyWAR02(),
vo.getCompanyCodeSys01WAR02(),
vo.getWarehouseCodeWar01WAR02(),
vo.getItemCodeItm01WAR02(),
vo.getWarehouseMotiveWar04WAR02(),
vo.getItemTypeWAR04(),
vo.getNoteWAR02(),
vo.getSerialNumbers(),
vo.getVariantCodeItm11WAR02(),
vo.getVariantCodeItm12WAR02(),
vo.getVariantCodeItm13WAR02(),
vo.getVariantCodeItm14WAR02(),
vo.getVariantCodeItm15WAR02(),
vo.getVariantTypeItm06WAR02(),
vo.getVariantTypeItm07WAR02(),
vo.getVariantTypeItm08WAR02(),
vo.getVariantTypeItm09WAR02(),
vo.getVariantTypeItm10WAR02()
);
res = bean.addWarehouseMovement(movVO,t1,serverLanguageId,username);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
}
else
for(int k=0;k<matrixVO.getColumnDescriptors().length;k++) {
colVO = (VariantsMatrixColumnVO)matrixVO.getColumnDescriptors()[k];
if (cells[i][k]!=null) {
vo = (MovementVO)voTemplate.clone();
try {
vo.setDeltaQtyWAR02((BigDecimal)cells[i][k]);
} catch (Exception e) {
continue;
}
sn.clear();
if (vo.getDeltaQtyWAR02().intValue()>0) {
sn.addAll(voTemplate.getSerialNumbers().subList(pos,pos+vo.getDeltaQtyWAR02().intValue()));
}
vo.setSerialNumbers(sn);
pos += vo.getDeltaQtyWAR02().intValue();
//PurchaseUtils.updateTotals(vo,currencyDecimals.intValue());
vo.setVariantCodeItm11WAR02(rowVO.getVariantCodeITM11());
vo.setVariantTypeItm06WAR02(rowVO.getVariantTypeITM06());
vo.setVariantCodeItm12WAR02(colVO.getVariantCodeITM12()==null?ApplicationConsts.JOLLY:colVO.getVariantCodeITM12());
vo.setVariantCodeItm13WAR02(colVO.getVariantCodeITM13()==null?ApplicationConsts.JOLLY:colVO.getVariantCodeITM13());
vo.setVariantCodeItm14WAR02(colVO.getVariantCodeITM14()==null?ApplicationConsts.JOLLY:colVO.getVariantCodeITM14());
vo.setVariantCodeItm15WAR02(colVO.getVariantCodeITM15()==null?ApplicationConsts.JOLLY:colVO.getVariantCodeITM15());
vo.setVariantTypeItm07WAR02(colVO.getVariantTypeITM07()==null?ApplicationConsts.JOLLY:colVO.getVariantTypeITM07());
vo.setVariantTypeItm08WAR02(colVO.getVariantTypeITM08()==null?ApplicationConsts.JOLLY:colVO.getVariantTypeITM08());
vo.setVariantTypeItm09WAR02(colVO.getVariantTypeITM09()==null?ApplicationConsts.JOLLY:colVO.getVariantTypeITM09());
vo.setVariantTypeItm10WAR02(colVO.getVariantTypeITM10()==null?ApplicationConsts.JOLLY:colVO.getVariantTypeITM10());
WarehouseMovementVO movVO = new WarehouseMovementVO(
vo.getProgressiveHie01WAR02(),
vo.getDeltaQtyWAR02(),
vo.getCompanyCodeSys01WAR02(),