(self, depreciation_start_date)
return super()._get_depreciation_stop_date(depreciation_start_date)
Compute stop date for the added method 'Percentage'.
Compute stop date for the added method 'Percentage'.
Compute stop date for the added method Percentage .
def _get_depreciation_stop_date(self, depreciation_start_date):
        """Compute stop date for the added method 'Percentage'."""
        if self.method_time == "percentage":
            number = 0
            percentage = 100.0
            stop_date = depreciation_start_date
            while percentage > 0:
                if number == 0 and self.prorata:
                    days = (date(stop_date.year, month=12, day=31) - stop_date).days + 1
                    year_days = (
                        date(stop_date.year, month=12, day=31)
                        - date(stop_date.year, month=1, day=1)
                    ).days + 1
                    percentage -= self.annual_percentage * days / year_days
                    stop_date += relativedelta(day=31, month=12)
                else:
                    if float_compare(percentage - self.annual_percentage, 0.0, 8) >= 0:
                        stop_date += relativedelta(years=1)
                    else:
                        # Remaining percentage is not whole year
                        year_days = (
                            date(stop_date.year + 1, month=12, day=31)
                            - date(stop_date.year + 1, month=1, day=1)
                        ).days + 1
                        days = int(year_days * percentage / self.annual_percentage)
                        stop_date += relativedelta(days=days)
                    percentage -= self.annual_percentage
                number += 1
            return stop_date
        return super()._get_depreciation_stop_date(depreciation_start_date)
def _get_depreciation_stop_date ( self , depreciation_start_date ) : if self . method_time == "percentage" : number = 0 percentage = 100.0 stop_date = depreciation_start_date while percentage > 0 : if number == 0 and self . prorata : days = ( date ( stop_date . year , month = 12 , day = 31 ) - stop_date ) . days + 1 year_days = ( date ( stop_date . year , month = 12 , day = 31 ) - date ( stop_date . year , month = 1 , day = 1 ) ) . days + 1 percentage -= self . annual_percentage * days / year_days stop_date += relativedelta ( day = 31 , month = 12 ) else : if float_compare ( percentage - self . annual_percentage , 0.0 , 8 ) >= 0 : stop_date += relativedelta ( years = 1 ) else : # Remaining percentage is not whole year year_days = ( date ( stop_date . year + 1 , month = 12 , day = 31 ) - date ( stop_date . year + 1 , month = 1 , day = 1 ) ) . days + 1 days = int ( year_days * percentage / self . annual_percentage ) stop_date += relativedelta ( days = days ) percentage -= self . annual_percentage number += 1 return stop_date return super ( ) . _get_depreciation_stop_date ( depreciation_start_date )