question: public String order ( Properties ctx , int WindowNo , GridTab mTab , GridField mField , Object value ) { Integer C_Order_ID = ( Integer ) value ; if ( isCalloutActive ( ) || C_Order_ID == null || C_Order_ID . intValue ( ) == 0 ) return "" ; mTab . setValue ( "C_Invoice_ID" , null ) ; mTab . setValue ( "C_Charge_ID" , null ) ; mTab . setValue ( "IsPrepayment" , Boolean . TRUE ) ; mTab . setValue ( "DiscountAmt" , Env . ZERO ) ; mTab . setValue ( "WriteOffAmt" , Env . ZERO ) ; mTab . setValue ( "IsOverUnderPayment" , Boolean . FALSE ) ; mTab . setValue ( "OverUnderAmt" , Env . ZERO ) ; Timestamp ts = ( Timestamp ) mTab . getValue ( "DateTrx" ) ; if ( ts == null ) ts = new Timestamp ( System . currentTimeMillis ( ) ) ; String sql = "SELECT COALESCE(Bill_BPartner_ID, C_BPartner_ID) as C_BPartner_ID " + ", C_Currency_ID " + ", GrandTotal " + "FROM C_Order WHERE C_Order_ID=?" ; PreparedStatement pstmt = null ; ResultSet rs = null ; try { pstmt = DB . prepareStatement ( sql , null ) ; pstmt . setInt ( 1 , C_Order_ID . intValue ( ) ) ; rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { mTab . setValue ( "C_BPartner_ID" , new Integer ( rs . getInt ( 1 ) ) ) ; int C_Currency_ID = rs . getInt ( 2 ) ; mTab . setValue ( "C_Currency_ID" , new Integer ( C_Currency_ID ) ) ; BigDecimal GrandTotal = rs . getBigDecimal ( 3 ) ; if ( GrandTotal == null ) GrandTotal = Env . ZERO ; mTab . setValue ( "PayAmt" , GrandTotal ) ; } } catch ( SQLException e ) { log . log ( Level . SEVERE , sql , e ) ; return e . getLocalizedMessage ( ) ; } finally { DB . close ( rs , pstmt ) ; } return docType ( ctx , WindowNo , mTab , mField , value ) ; }
target:  Payment_Order. when Waiting Payment Order selected - set C_Currency_ID - C_BPartner_ID - DiscountAmt = C_Invoice_Discount (ID, DateTrx) - PayAmt = invoiceOpen (ID) - Discount - WriteOffAmt = 0