#NEWLINE# def get_calculated_price( self , request ) : #NEWLINE# #INDENT# '\n        Returns the calculated gross price of the product based on property\n        values and the price calculation field of the product.\n        ' #NEWLINE# pc = self . product . price_calculation #NEWLINE# tokens = self . product . price_calculation . split ( ' ' ) #NEWLINE# for token in tokens : #NEWLINE# #INDENT# if token . startswith ( 'property' ) : #NEWLINE# #INDENT# mo = re . match ( 'property\\((\\d+)\\)' , token ) #NEWLINE# ppv = self . properties . filter ( property__id = mo . groups ( ) [ 0 ] ) [ 0 ] #NEWLINE# if ppv . property . is_select_field : #NEWLINE# #INDENT# po = PropertyOption . objects . get ( pk = ppv . value ) #NEWLINE# value = po . price #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = float ( ppv . value ) #NEWLINE# #UNINDENT# pc = pc . replace ( token , str ( self ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if token . startswith ( 'number' ) : #NEWLINE# #INDENT# mo = re . match ( 'number\\((\\d+)\\)' , token ) #NEWLINE# pc = pc . replace ( token , mo . groups ( ) [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if token . startswith ( 'product' ) : #NEWLINE# #INDENT# mo = re . match ( 'product\\((.+)\\)' , token ) #NEWLINE# value = getattr ( self . product , mo . groups ( ) [ 0 ] ) #NEWLINE# pc = pc . replace ( token , str ( value ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return eval ( pc )