private void addRow(VariantBarcodeVO barcodeVO,PriceItemVO priceItemVO) {
ArrayList sn = new ArrayList();
DetailSaleDocRowVO vo = new DetailSaleDocRowVO();
if (barcodeVO!=null) {
vo.setVariantCodeItm11DOC02(barcodeVO.getVariantCodeItm11ITM22());
vo.setVariantCodeItm12DOC02(barcodeVO.getVariantCodeItm12ITM22());
vo.setVariantCodeItm13DOC02(barcodeVO.getVariantCodeItm13ITM22());
vo.setVariantCodeItm14DOC02(barcodeVO.getVariantCodeItm14ITM22());
vo.setVariantCodeItm15DOC02(barcodeVO.getVariantCodeItm15ITM22());
vo.setVariantTypeItm06DOC02(barcodeVO.getVariantTypeItm06ITM22());
vo.setVariantTypeItm07DOC02(barcodeVO.getVariantTypeItm07ITM22());
vo.setVariantTypeItm08DOC02(barcodeVO.getVariantTypeItm08ITM22());
vo.setVariantTypeItm09DOC02(barcodeVO.getVariantTypeItm09ITM22());
vo.setVariantTypeItm10DOC02(barcodeVO.getVariantTypeItm10ITM22());
}
else {
vo.setVariantCodeItm11DOC02(ApplicationConsts.JOLLY);
vo.setVariantCodeItm12DOC02(ApplicationConsts.JOLLY);
vo.setVariantCodeItm13DOC02(ApplicationConsts.JOLLY);
vo.setVariantCodeItm14DOC02(ApplicationConsts.JOLLY);
vo.setVariantCodeItm15DOC02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm06DOC02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm07DOC02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm08DOC02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm09DOC02(ApplicationConsts.JOLLY);
vo.setVariantTypeItm10DOC02(ApplicationConsts.JOLLY);
}
// check for variants level price...
if (priceItemVO.getUseVariant1ITM01().equals(Boolean.TRUE) ||
priceItemVO.getUseVariant2ITM01().equals(Boolean.TRUE) ||
priceItemVO.getUseVariant3ITM01().equals(Boolean.TRUE) ||
priceItemVO.getUseVariant4ITM01().equals(Boolean.TRUE) ||
priceItemVO.getUseVariant5ITM01().equals(Boolean.TRUE)) {
Response res = ClientUtils.getData("loadVariantsPrice",new Object[]{barcodeVO,customerVO.getPricelistCodeSal01SAL07()});
if (!res.isError()) {
java.util.List rows = ((VOListResponse)res).getRows();
if (rows.size()==1) {
VariantsPriceVO vpVO = (VariantsPriceVO)rows.get(0);
priceItemVO.setValueSAL02(vpVO.getValueSAL11());
}
}
}
vo.setCompanyCodeSys01DOC02(priceItemVO.getCompanyCodeSys01());
Calendar cal = Calendar.getInstance();
vo.setDocYearDOC02(new BigDecimal(cal.get(cal.YEAR)));
vo.setDocTypeDOC02(ApplicationConsts.SALE_DESK_DOC_TYPE);
vo.setDeliveryDateDOC02(new java.sql.Date(System.currentTimeMillis()));
vo.setCurrencyCodeReg03DOC01(customerVO.getCurrencyCodeReg03SAL01());
vo.setProgressiveHie01DOC02(priceItemVO.getProgressiveHie01ITM01());
vo.setDecimalsReg02DOC02(priceItemVO.getDecimalsREG02());
vo.setDescriptionSYS10(priceItemVO.getItemDescriptionSYS10());
vo.setItemCodeItm01DOC02(priceItemVO.getItemCodeItm01());
vo.setMinSellingQtyItm01DOC02(priceItemVO.getMinSellingQtyITM01());
vo.setMinSellingQtyUmCodeReg02DOC02(priceItemVO.getMinSellingQtyUmCodeReg02ITM01());
vo.setProgressiveHie01ITM01(priceItemVO.getProgressiveHie01ITM01());
vo.setProgressiveHie02DOC02(warehouseVO.getProgressiveHie02WAR01());
vo.setQtyDOC02(new BigDecimal(1));
vo.setSerialNumbers(sn);
vo.setStartDateSal02DOC02(priceItemVO.getStartDateSAL02());
vo.setEndDateSal02DOC02(priceItemVO.getEndDateSAL02());
vo.setValueReg01DOC02(priceItemVO.getValueREG01());
vo.setValueSal02DOC02(priceItemVO.getValueSAL02());
vo.setVatCodeItm01DOC02(priceItemVO.getVatCodeReg01ITM01());
vo.setVatDescriptionDOC02(priceItemVO.getVatDescriptionSYS10());
vo.setDeductibleReg01DOC02(priceItemVO.getDeductibleREG01());
// check if there already exist another row for the same item + variants...
DetailSaleDocRowVO oldVO = null;
int rowFound = -1;
for(int i=0;i<grid.getVOListTableModel().getRowCount();i++) {
oldVO = (DetailSaleDocRowVO)grid.getVOListTableModel().getObjectForRow(i);
if (oldVO.getCompanyCodeSys01DOC02().equals(vo.getCompanyCodeSys01DOC02()) &&
oldVO.getItemCodeItm01DOC02().equals(vo.getItemCodeItm01DOC02()) &&
oldVO.getVariantCodeItm11DOC02().equals(vo.getVariantCodeItm11DOC02()) &&
oldVO.getVariantCodeItm12DOC02().equals(vo.getVariantCodeItm12DOC02()) &&
oldVO.getVariantCodeItm13DOC02().equals(vo.getVariantCodeItm13DOC02()) &&
oldVO.getVariantCodeItm14DOC02().equals(vo.getVariantCodeItm14DOC02()) &&
oldVO.getVariantCodeItm15DOC02().equals(vo.getVariantCodeItm15DOC02()) &&
oldVO.getVariantTypeItm06DOC02().equals(vo.getVariantTypeItm06DOC02()) &&
oldVO.getVariantTypeItm07DOC02().equals(vo.getVariantTypeItm07DOC02()) &&
oldVO.getVariantTypeItm08DOC02().equals(vo.getVariantTypeItm08DOC02()) &&
oldVO.getVariantTypeItm09DOC02().equals(vo.getVariantTypeItm09DOC02()) &&
oldVO.getVariantTypeItm10DOC02().equals(vo.getVariantTypeItm10DOC02())) {
rowFound = i;
break;
}
}
int selRow = rowFound;
if (rowFound!=-1) {
DetailSaleDocRowVO voFound = (DetailSaleDocRowVO)grid.getVOListTableModel().getObjectForRow(rowFound);
vo = voFound;
vo.setQtyDOC02(vo.getQtyDOC02().add(new BigDecimal(1)));
}
else {
grid.getVOListTableModel().addObject(vo);
selRow = grid.getVOListTableModel().getRowCount()-1;
}
updateRow(vo);
grid.repaint();
grid.setRowSelectionInterval(selRow,selRow);
updateContext();
updateTotals();
new Thread() {
public void run() {
ArrayList items = new ArrayList();
DetailSaleDocRowVO rowVO = null;
for(int i=0;i<grid.getVOListTableModel().getRowCount();i++) {
rowVO = (DetailSaleDocRowVO)grid.getVOListTableModel().getObjectForRow(i);
items.add(rowVO.getItemCodeItm01DOC02());
}
Response res = ClientUtils.getData("loadItemsSoldToOtherCustomers",new Object[]{defaultCompanyCodeSys01,items});
if (!res.isError()) {
java.util.List rows = ((VOListResponse)res).getRows();
if (rows.size()==0)