'Set Rate'

def set_rate(self):

    if (self.depreciation_type == 'straight'):
        if self.lifetime:
            self.depreciation_rate = (100 / self.lifetime).quantize(Decimal('00.01'), rounding=ROUND_UP)
    elif (self.depreciation_type == 'reducing'):
        if (not self.check_depreciate()):
            return Decimal('0.00')
        self.depreciation_rate = Decimal(str((100 / (1 - math.pow((self.endlife_value / self.initial_value), (1 / self.lifetime)))))).quantize(Decimal('00.01'), rounding=ROUND_UP)
    else:
        return Decimal('0.00')
    if (self.depreciation_rate == Decimal('100.00')):
        self.depreciation_rate = Decimal('99.99')
    self.save()
    return self
