#NEWLINE# def req_item_in_shipment( shipment_item , shipment_type , req_items ) : #NEWLINE# #INDENT# '\n        Checks if a shipment item is in a request and updates req_item\n        and the shipment.\n    ' #NEWLINE# shipment_item_table = ( 'inv_%s_item' % shipment_type ) #NEWLINE# try : #NEWLINE# #INDENT# item_id = shipment_item [ shipment_item_table ] . item_id #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# item_id = shipment_item . inv_inv_item . item_id #NEWLINE# #UNINDENT# if ( shipment_item_table in req_items ) : #NEWLINE# #INDENT# shipment_to_req_type = dict ( recv = 'fulfil' , send = 'transit' ) #NEWLINE# quantity_req_type = ( 'quantity_%s' % shipment_to_req_type [ shipment_type ] ) #NEWLINE# req_item = req_items [ item_id ] #NEWLINE# req_item_id = req_item . id #NEWLINE# quantity = ( req_item [ quantity_req_type ] + ( ( shipment_item [ shipment_item_table ] . pack_quantity / req_item . pack_quantity ) * shipment_item [ shipment_item_table ] . quantity ) ) #NEWLINE# quantity = min ( quantity , req_item . quantity ) #NEWLINE# s3db . req_req_item [ req_item_id ] = { #NEWLINE# #INDENT# quantity_req_type : quantity , #NEWLINE# #UNINDENT# } #NEWLINE# s3db [ shipment_item_table ] [ shipment_item [ shipment_item_table ] . id ] = dict ( req_item_id = req_item_id ) #NEWLINE# return ( req_item . req_id , req_item . id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( None , None )