// check for already existing item for qty 1 and serial num enabled...
if (panel.isSerialNumberRequired()) {
DetailSaleDocRowVO itemVO = (DetailSaleDocRowVO)newPersistentObject;
for(int i=0;i<panel.getGrid().getVOListTableModel().getRowCount();i++) {
GridSaleDocRowVO vo =(GridSaleDocRowVO)panel.getGrid().getVOListTableModel().getObjectForRow(i);
if (vo.getItemCodeItm01DOC02().equals(itemVO.getItemCodeItm01DOC02()) &&
vo.getVariantCodeItm11DOC02().equals(itemVO.getVariantCodeItm11DOC02()) &&
vo.getVariantCodeItm12DOC02().equals(itemVO.getVariantCodeItm12DOC02()) &&
vo.getVariantCodeItm13DOC02().equals(itemVO.getVariantCodeItm13DOC02()) &&
vo.getVariantCodeItm14DOC02().equals(itemVO.getVariantCodeItm14DOC02()) &&
vo.getVariantCodeItm15DOC02().equals(itemVO.getVariantCodeItm15DOC02()) &&
vo.getVariantTypeItm06DOC02().equals(itemVO.getVariantTypeItm06DOC02()) &&
vo.getVariantTypeItm07DOC02().equals(itemVO.getVariantTypeItm07DOC02()) &&
vo.getVariantTypeItm08DOC02().equals(itemVO.getVariantTypeItm08DOC02()) &&
vo.getVariantTypeItm09DOC02().equals(itemVO.getVariantTypeItm09DOC02()) &&
vo.getVariantTypeItm10DOC02().equals(itemVO.getVariantTypeItm10DOC02())) {
// load old row..
SaleDocRowPK pk = new SaleDocRowPK(
vo.getCompanyCodeSys01DOC02(),
vo.getDocTypeDOC02(),vo.getDocYearDOC02(),
vo.getDocNumberDOC02(),
vo.getItemCodeItm01DOC02(),
vo.getVariantTypeItm06DOC02(),
vo.getVariantCodeItm11DOC02(),
vo.getVariantTypeItm07DOC02(),
vo.getVariantCodeItm12DOC02(),
vo.getVariantTypeItm08DOC02(),
vo.getVariantCodeItm13DOC02(),
vo.getVariantTypeItm09DOC02(),
vo.getVariantCodeItm14DOC02(),
vo.getVariantTypeItm10DOC02(),
vo.getVariantCodeItm15DOC02()
);
res = ClientUtils.getData("loadSaleDocRow",pk);
if (res.isError())
return res;
DetailSaleDocRowVO oldVO = (DetailSaleDocRowVO)((VOResponse)res).getVo();
DetailSaleDocRowVO newVO = (DetailSaleDocRowVO)oldVO.clone();
newVO.setQtyDOC02(oldVO.getQtyDOC02().add(new BigDecimal(1)));
newVO.setSerialNumbers(itemVO.getSerialNumbers());
newVO.getSerialNumbers().addAll(oldVO.getSerialNumbers());
// update qty...
res = ClientUtils.getData(
"updateSaleDocRow",
new ValueObject[]{
oldVO,
newVO
}
);
return res;
}
}
}
// the item has variants...
res = ClientUtils.getData(
"insertSaleDocRows",
new Object[]{
newPersistentObject,
panel.getVariantsPanel().getVariantsMatrixVO(),
panel.getVariantsPanel().getCells(),
panel.getParentVO().getDecimalsREG03()
}
);
}
//Response res = ClientUtils.getData("insertSaleDocRow",newPersistentObject);
if (!res.isError()) {
DetailSaleDocRowVO vo = (DetailSaleDocRowVO)((VOResponse)res).getVo();
pk = new SaleDocRowPK(
vo.getCompanyCodeSys01DOC02(),
vo.getDocTypeDOC02(),
vo.getDocYearDOC02(),
vo.getDocNumberDOC02(),
vo.getItemCodeItm01DOC02(),
vo.getVariantTypeItm06DOC02(),
vo.getVariantCodeItm11DOC02(),
vo.getVariantTypeItm07DOC02(),
vo.getVariantCodeItm12DOC02(),
vo.getVariantTypeItm08DOC02(),
vo.getVariantCodeItm13DOC02(),
vo.getVariantTypeItm09DOC02(),
vo.getVariantCodeItm14DOC02(),
vo.getVariantTypeItm10DOC02(),
vo.getVariantCodeItm15DOC02()
);
}
return res;
}