#NEWLINE# def _add_mfs( self , start_date , end_date , invoice = None , proforma = None ) : #NEWLINE# #INDENT# ( prorated , percent ) = self . _get_proration_status_and_percent ( start_date , end_date ) #NEWLINE# context = self . _build_entry_context ( { #NEWLINE# #INDENT# 'name' : self . plan . name , #NEWLINE# 'unit' : self . plan . interval , #NEWLINE# 'product_code' : self . plan . product_code , #NEWLINE# 'start_date' : start_date , #NEWLINE# 'end_date' : end_date , #NEWLINE# 'prorated' : prorated , #NEWLINE# 'proration_percentage' : percent , #NEWLINE# 'context' : 'metered-feature' , #NEWLINE# #UNINDENT# } ) #NEWLINE# for metered_feature in self . plan . metered_features . all ( ) : #NEWLINE# #INDENT# consumed_units = self . _get_consumed_units ( metered_feature , percent , start_date , end_date ) #NEWLINE# context . update ( { #NEWLINE# #INDENT# 'metered_feature' : metered_feature , #NEWLINE# 'unit' : metered_feature . unit , #NEWLINE# 'name' : metered_feature . name , #NEWLINE# 'product_code' : metered_feature . product_code , #NEWLINE# #UNINDENT# } ) #NEWLINE# description = self . _entry_description ( context ) #NEWLINE# unit = self . _entry_unit ( context ) #NEWLINE# DocumentEntry . objects . create ( invoice = invoice , proforma = proforma , description = description , unit = unit , quantity = consumed_units , prorated = prorated , unit_price = metered_feature . price_per_unit , product_code = metered_feature . product_code , start_date = start_date , end_date = end_date )