throw new Exception(t17);
}
// check if all items are available...
GridSaleDocRowVO vo = null;
DetailSaleDocRowVO detailVO = null;
gridParams = new GridParams();
BookedItemQtyVO availVO = null;
java.util.List availRows = null;
for(int i=0;i<rows.size();i++) {
vo = (GridSaleDocRowVO)rows.get(i);
gridParams.getOtherGridParams().put(ApplicationConsts.WAREHOUSE_CODE,docVO.getWarehouseCodeWar01DOC01());
gridParams.getOtherGridParams().put(ApplicationConsts.ITEM_PK,new ItemPK(vo.getCompanyCodeSys01DOC02(),vo.getItemCodeItm01DOC02()));
res = availAction.loadBookedItems(variant1Descriptions,variant2Descriptions,variant3Descriptions,variant4Descriptions,variant5Descriptions,gridParams,serverLanguageId,username,companiesList);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
availRows = ((VOListResponse)res).getRows();
if (availRows.size()>0) {
availVO = (BookedItemQtyVO) availRows.get(0);
if (availVO.getAvailableQtyWAR03().doubleValue()>=vo.getQtyDOC02().doubleValue()) {
// unload item from the specified warehouse...
res = loadSaleDocRowBean.loadSaleDocRow(
variant1Descriptions,variant2Descriptions,variant3Descriptions,variant4Descriptions,variant5Descriptions,
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()
),
serverLanguageId,
username
);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
detailVO = (DetailSaleDocRowVO)((VOResponse)res).getVo();
WarehouseMovementVO movVO = new WarehouseMovementVO(
detailVO.getProgressiveHie01DOC02(),
vo.getQtyDOC02(),
vo.getCompanyCodeSys01DOC02(),
docVO.getWarehouseCodeWar01DOC01(),
vo.getItemCodeItm01DOC02(),
ApplicationConsts.WAREHOUSE_MOTIVE_DIRECTLY_UNLOAD,
ApplicationConsts.ITEM_GOOD,
t2+" "+docVO.getDocTypeDOC01()+"/"+docVO.getDocNumberDOC01()+"/"+docVO.getDocYearDOC01(),
detailVO.getSerialNumbers(),
vo.getVariantCodeItm11DOC02(),
vo.getVariantCodeItm12DOC02(),
vo.getVariantCodeItm13DOC02(),
vo.getVariantCodeItm14DOC02(),
vo.getVariantCodeItm15DOC02(),
vo.getVariantTypeItm06DOC02(),
vo.getVariantTypeItm07DOC02(),
vo.getVariantTypeItm08DOC02(),
vo.getVariantTypeItm09DOC02(),
vo.getVariantTypeItm10DOC02()
);
res = movBean.addWarehouseMovement(movVO,t15,serverLanguageId,username);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
}
else {
throw new Exception(t1);
}
}
else {
throw new Exception(t1);
}
}
} // end if SALE_DESK_DOC_TYPE (check item availabilities...)
// check if this document is a sale invoice and has a linked sale document:
// if this is the case, then the linked document will be updated...
if ((docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_INVOICE_FROM_DN_DOC_TYPE) ||
docVO.getDocTypeDOC01().equals(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE)) &&
docVO.getDocNumberDoc01DOC01()!=null
) {
SaleDocPK refPK = new SaleDocPK(
docVO.getCompanyCodeSys01Doc01DOC01(),
docVO.getDocTypeDoc01DOC01(),
docVO.getDocYearDoc01DOC01(),
docVO.getDocNumberDoc01DOC01()
);
// retrieve ref. document item rows...
GridSaleDocRowVO vo = null;
DetailSaleDocRowVO refDetailVO = null;
BigDecimal qty = null;
BigDecimal invoiceQty = null;
String docType = null;
BigDecimal docYear = null;
BigDecimal docNumber = null;
BigDecimal rowNumber = null;
for(int i=0;i<rows.size();i++) {
vo = (GridSaleDocRowVO)rows.get(i);
res = loadSaleDocRowBean.loadSaleDocRow(
variant1Descriptions,variant2Descriptions,variant3Descriptions,variant4Descriptions,variant5Descriptions,
new SaleDocRowPK(
docVO.getCompanyCodeSys01Doc01DOC01(),
docVO.getDocTypeDoc01DOC01(),
docVO.getDocYearDoc01DOC01(),
docVO.getDocNumberDoc01DOC01(),
vo.getItemCodeItm01DOC02(),
vo.getVariantTypeItm06DOC02(),
vo.getVariantCodeItm11DOC02(),
vo.getVariantTypeItm07DOC02(),
vo.getVariantCodeItm12DOC02(),
vo.getVariantTypeItm08DOC02(),
vo.getVariantCodeItm13DOC02(),
vo.getVariantTypeItm09DOC02(),
vo.getVariantCodeItm14DOC02(),
vo.getVariantTypeItm10DOC02(),
vo.getVariantCodeItm15DOC02()
),
serverLanguageId,
username
);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
refDetailVO = (DetailSaleDocRowVO)((VOResponse)res).getVo();
refDetailVO.setInvoiceQtyDOC02(
refDetailVO.getInvoiceQtyDOC02().add(vo.getQtyDOC02()).setScale(docVO.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
if (refDetailVO.getInvoiceQtyDOC02().doubleValue()>refDetailVO.getQtyDOC02().doubleValue())
refDetailVO.setInvoiceQtyDOC02( refDetailVO.getQtyDOC02() );
// update ref. item row...
pstmt = conn.prepareStatement(
"update DOC02_SELLING_ITEMS set INVOICE_QTY=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=? where "+
"COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ITEM_CODE_ITM01=? and "+
"VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
"VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
"VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
"VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
"VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? "
);
pstmt.setBigDecimal(1,refDetailVO.getInvoiceQtyDOC02());
pstmt.setString(2,username);
pstmt.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(4,refDetailVO.getCompanyCodeSys01DOC02());
pstmt.setString(5,refDetailVO.getDocTypeDOC02());
pstmt.setBigDecimal(6,refDetailVO.getDocYearDOC02());
pstmt.setBigDecimal(7,refDetailVO.getDocNumberDOC02());
pstmt.setString(8,refDetailVO.getItemCodeItm01DOC02());
pstmt.setString(9,refDetailVO.getVariantTypeItm06DOC02());
pstmt.setString(10,refDetailVO.getVariantCodeItm11DOC02());
pstmt.setString(11,refDetailVO.getVariantTypeItm07DOC02());
pstmt.setString(12,refDetailVO.getVariantCodeItm12DOC02());
pstmt.setString(13,refDetailVO.getVariantTypeItm08DOC02());
pstmt.setString(14,refDetailVO.getVariantCodeItm13DOC02());
pstmt.setString(15,refDetailVO.getVariantTypeItm09DOC02());
pstmt.setString(16,refDetailVO.getVariantCodeItm14DOC02());
pstmt.setString(17,refDetailVO.getVariantTypeItm10DOC02());
pstmt.setString(18,refDetailVO.getVariantCodeItm15DOC02());
pstmt.execute();
pstmt.close();
// update ref. item row in the out delivery note...
pstmt2 = conn.prepareStatement(
"select QTY,INVOICE_QTY,DOC_TYPE,DOC_YEAR,DOC_NUMBER,ROW_NUMBER from DOC10_OUT_DELIVERY_NOTE_ITEMS where "+
"COMPANY_CODE_SYS01=? and DOC_TYPE_DOC01=? and DOC_YEAR_DOC01=? and DOC_NUMBER_DOC01=? and ITEM_CODE_ITM01=? and INVOICE_QTY<QTY and "+
"VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
"VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
"VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
"VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
"VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? "
);
qty = null;
invoiceQty = null;
pstmt2.setString(1,refDetailVO.getCompanyCodeSys01DOC02());
pstmt2.setString(2,refDetailVO.getDocTypeDOC02());
pstmt2.setBigDecimal(3,refDetailVO.getDocYearDOC02());
pstmt2.setBigDecimal(4,refDetailVO.getDocNumberDOC02());
pstmt2.setString(5,refDetailVO.getItemCodeItm01DOC02());
pstmt2.setString(6,refDetailVO.getVariantTypeItm06DOC02());
pstmt2.setString(7,refDetailVO.getVariantCodeItm11DOC02());
pstmt2.setString(8,refDetailVO.getVariantTypeItm07DOC02());
pstmt2.setString(9,refDetailVO.getVariantCodeItm12DOC02());
pstmt2.setString(10,refDetailVO.getVariantTypeItm08DOC02());
pstmt2.setString(11,refDetailVO.getVariantCodeItm13DOC02());
pstmt2.setString(12,refDetailVO.getVariantTypeItm09DOC02());
pstmt2.setString(13,refDetailVO.getVariantCodeItm14DOC02());
pstmt2.setString(14,refDetailVO.getVariantTypeItm10DOC02());
pstmt2.setString(15,refDetailVO.getVariantCodeItm15DOC02());
rset = pstmt2.executeQuery();
// it only updates one row, that matches the where clause...
if(rset.next()) {
qty = rset.getBigDecimal(1);
invoiceQty = rset.getBigDecimal(2);
docType = rset.getString(3);
docYear = rset.getBigDecimal(4);
docNumber = rset.getBigDecimal(5);
rowNumber = rset.getBigDecimal(6);
}
rset.close();
pstmt2.close();
if (qty!=null && invoiceQty!=null) {
if (invoiceQty.doubleValue()+vo.getQtyDOC02().doubleValue()<=qty.doubleValue())
qty = invoiceQty.add(vo.getQtyDOC02());
pstmt = conn.prepareStatement(
"update DOC10_OUT_DELIVERY_NOTE_ITEMS set INVOICE_QTY=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=? where "+
"COMPANY_CODE_SYS01=? and DOC_TYPE_DOC01=? and DOC_YEAR_DOC01=? and DOC_NUMBER_DOC01=? and ITEM_CODE_ITM01=? and "+
"DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ROW_NUMBER=? and "+
"VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
"VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
"VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
"VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
"VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? "
);
pstmt.setBigDecimal(1,qty);
pstmt.setString(2,username);
pstmt.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(4,refDetailVO.getCompanyCodeSys01DOC02());
pstmt.setString(5,refDetailVO.getDocTypeDOC02());
pstmt.setBigDecimal(6,refDetailVO.getDocYearDOC02());
pstmt.setBigDecimal(7,refDetailVO.getDocNumberDOC02());
pstmt.setString(8,refDetailVO.getItemCodeItm01DOC02());
pstmt.setString(9,docType);
pstmt.setBigDecimal(10,docYear);
pstmt.setBigDecimal(11,docNumber);
pstmt.setBigDecimal(12,rowNumber);
pstmt.setString(13,refDetailVO.getVariantTypeItm06DOC02());
pstmt.setString(14,refDetailVO.getVariantCodeItm11DOC02());
pstmt.setString(15,refDetailVO.getVariantTypeItm07DOC02());
pstmt.setString(16,refDetailVO.getVariantCodeItm12DOC02());
pstmt.setString(17,refDetailVO.getVariantTypeItm08DOC02());
pstmt.setString(18,refDetailVO.getVariantCodeItm13DOC02());
pstmt.setString(19,refDetailVO.getVariantTypeItm09DOC02());
pstmt.setString(20,refDetailVO.getVariantCodeItm14DOC02());
pstmt.setString(21,refDetailVO.getVariantTypeItm10DOC02());
pstmt.setString(22,refDetailVO.getVariantCodeItm15DOC02());
pstmt.execute();
pstmt.close();
}
} // end for (used to update invoice qtys in referred docs...)