
    
-- 'cols' : [
 --  { 'header' : 'SP#' ,  'dataIndex': 'cohead_number' },
 --  { 'header' : 'Shipping Asset' ,  'dataIndex': 'shipping_asset_total' } 


-- ]
-- }
-- JSON END


SELECT
    cohead_number,
    
    -- shippnig asset.
    (
        SELECT
            sum(gltrans_amount)
        FROM
            gltrans
        WHERE
                gltrans_accnt_id = (SELECT costcat_shipasset_accnt_id FROM costcat limiT 1)
            AND
                (
                    (
                        gltrans_docnumber like cohead_number || '-%'
                        OR 
                        gltrans_docnumber = cohead_number
                        AND
                        gltrans_source = 'S/R'
                    )
                OR
                    (
                        gltrans_docnumber = 'FIFO-COHEAD-' || cohead_number
                        
                        AND
                        gltrans_source = 'G/L'
                    )
                )
            AND
                NOT gltrans_deleted
            AND
                gltrans_posted
            
    
    
    ) as shipping_asset_total
    
    
    FROM
        cohead
    ORDER BY
        cohead_number ASC;
    
    
    
    