docVO.getDocYearDoc06DOC06(),
docVO.getDocNumberDoc06DOC06()
);
// retrieve ref. document item rows...
GridPurchaseDocRowVO vo = null;
DetailPurchaseDocRowVO 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 = (GridPurchaseDocRowVO)rows.get(i);
refDetailVO = rowAction.loadPurchaseDocRow(
variant1Descriptions,variant2Descriptions,variant3Descriptions,variant4Descriptions,variant5Descriptions,
new PurchaseDocRowPK(
docVO.getCompanyCodeSys01Doc06DOC06(),
docVO.getDocTypeDoc06DOC06(),
docVO.getDocYearDoc06DOC06(),
docVO.getDocNumberDoc06DOC06(),
vo.getItemCodeItm01DOC07(),
vo.getVariantTypeItm06DOC07(),
vo.getVariantCodeItm11DOC07(),
vo.getVariantTypeItm07DOC07(),
vo.getVariantCodeItm12DOC07(),
vo.getVariantTypeItm08DOC07(),
vo.getVariantCodeItm13DOC07(),
vo.getVariantTypeItm09DOC07(),
vo.getVariantCodeItm14DOC07(),
vo.getVariantTypeItm10DOC07(),
vo.getVariantCodeItm15DOC07()
),
serverLanguageId,username
);
refDetailVO.setInvoiceQtyDOC07(
refDetailVO.getInvoiceQtyDOC07().add(vo.getQtyDOC07()).setScale(docVO.getDecimalsREG03().intValue(),BigDecimal.ROUND_HALF_UP)
);
if (refDetailVO.getInvoiceQtyDOC07().doubleValue()>refDetailVO.getQtyDOC07().doubleValue())
refDetailVO.setInvoiceQtyDOC07( refDetailVO.getQtyDOC07() );
// update ref. item row...
pstmt = conn.prepareStatement(
"update DOC07_PURCHASE_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.getInvoiceQtyDOC07());
pstmt.setString(2,username);
pstmt.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()));
pstmt.setString(4,refDetailVO.getCompanyCodeSys01DOC07());
pstmt.setString(5,refDetailVO.getDocTypeDOC07());
pstmt.setBigDecimal(6,refDetailVO.getDocYearDOC07());
pstmt.setBigDecimal(7,refDetailVO.getDocNumberDOC07());
pstmt.setString(8,refDetailVO.getItemCodeItm01DOC07());
pstmt.setString(9,refDetailVO.getVariantTypeItm06DOC07());
pstmt.setString(10,refDetailVO.getVariantCodeItm11DOC07());
pstmt.setString(11,refDetailVO.getVariantTypeItm07DOC07());
pstmt.setString(12,refDetailVO.getVariantCodeItm12DOC07());
pstmt.setString(13,refDetailVO.getVariantTypeItm08DOC07());
pstmt.setString(14,refDetailVO.getVariantCodeItm13DOC07());
pstmt.setString(15,refDetailVO.getVariantTypeItm09DOC07());
pstmt.setString(16,refDetailVO.getVariantCodeItm14DOC07());
pstmt.setString(17,refDetailVO.getVariantTypeItm10DOC07());
pstmt.setString(18,refDetailVO.getVariantCodeItm15DOC07());
pstmt.execute();
pstmt.close();
// update ref. item row in the in delivery note...
pstmt2 = conn.prepareStatement(
"select QTY,INVOICE_QTY,DOC_TYPE,DOC_YEAR,DOC_NUMBER,ROW_NUMBER from DOC09_IN_DELIVERY_NOTE_ITEMS where "+
"COMPANY_CODE_SYS01=? and DOC_TYPE_DOC06=? and DOC_YEAR_DOC06=? and DOC_NUMBER_DOC06=? 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.getCompanyCodeSys01DOC07());
pstmt2.setString(2,refDetailVO.getDocTypeDOC07());
pstmt2.setBigDecimal(3,refDetailVO.getDocYearDOC07());
pstmt2.setBigDecimal(4,refDetailVO.getDocNumberDOC07());
pstmt2.setString(5,refDetailVO.getItemCodeItm01DOC07());
pstmt2.setString(6,refDetailVO.getVariantTypeItm06DOC07());
pstmt2.setString(7,refDetailVO.getVariantCodeItm11DOC07());
pstmt2.setString(8,refDetailVO.getVariantTypeItm07DOC07());
pstmt2.setString(9,refDetailVO.getVariantCodeItm12DOC07());
pstmt2.setString(10,refDetailVO.getVariantTypeItm08DOC07());
pstmt2.setString(11,refDetailVO.getVariantCodeItm13DOC07());
pstmt2.setString(12,refDetailVO.getVariantTypeItm09DOC07());
pstmt2.setString(13,refDetailVO.getVariantCodeItm14DOC07());
pstmt2.setString(14,refDetailVO.getVariantTypeItm10DOC07());
pstmt2.setString(15,refDetailVO.getVariantCodeItm15DOC07());
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.getQtyDOC07().doubleValue()<=qty.doubleValue())
qty = invoiceQty.add(vo.getQtyDOC07());
pstmt = conn.prepareStatement(
"update DOC09_IN_DELIVERY_NOTE_ITEMS set INVOICE_QTY=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=? where "+
"COMPANY_CODE_SYS01=? and DOC_TYPE_DOC06=? and DOC_YEAR_DOC06=? and DOC_NUMBER_DOC06=? and ITEM_CODE_ITM01=? and "+
"DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ROW_NUMBER=? and "+