'Fetch RM rate as per today\'s valuation rate and calculate totals'

def calculate_rm_cost(self):

    total_rm_cost = 0
    base_total_rm_cost = 0
    for d in self.get(u'items'):
        d.base_rate = (flt(d.rate) * flt(self.conversion_rate))
        d.amount = (flt(d.rate, self.precision(u'rate', d)) * flt(d.stock_qty, self.precision(u'stock_qty', d)))
        d.base_amount = (d.amount * flt(self.conversion_rate))
        d.qty_consumed_per_unit = (flt(d.stock_qty, self.precision(u'stock_qty', d)) / flt(self.quantity, self.precision(u'quantity')))
        total_rm_cost += d.amount
        base_total_rm_cost += d.base_amount
    self.raw_material_cost = total_rm_cost
    self.base_raw_material_cost = base_total_rm_cost
