Exemplo n.º 1
0
    def get_revised_limits(self, obj):
        """
        Gets the future Carbon Intensity Limits for the compliance period,
        if applicable
        """
        diesel_limit = CreditCalculationService.get_later(
            compliance_period_id=obj.id,
            effective_date=date.today(),
            fuel_class__fuel_class="Diesel",
            model_name="CarbonIntensityLimit")

        gasoline_limit = CreditCalculationService.get_later(
            compliance_period_id=obj.id,
            effective_date=date.today(),
            fuel_class__fuel_class="Gasoline",
            model_name="CarbonIntensityLimit")

        return {
            "diesel": {
                "fuel": "Diesel Class",
                "density": diesel_limit.density,
                "effective_date": diesel_limit.effective_date,
                "expiration_date": diesel_limit.expiration_date
            } if diesel_limit else None,
            "gasoline": {
                "fuel": "Gasoline Class",
                "density": gasoline_limit.density,
                "effective_date": gasoline_limit.effective_date,
                "expiration_date": gasoline_limit.expiration_date
            } if gasoline_limit else None
        }
Exemplo n.º 2
0
    def get_revised_density(self, obj):
        """
        Gets the future density value, if applicable
        """
        density = CreditCalculationService.get_later(
            model_name="EnergyDensity",
            category_id=obj.id,
            effective_date=date.today())

        if not density:
            return None

        return {
            "density": density.density,
            "effective_date": density.effective_date
        }
Exemplo n.º 3
0
    def get_revised_gasoline_ratio(self, obj):
        """
        Gets the future gasoline ratio, if applicable
        """
        ratio = CreditCalculationService.get_later(
            model_name="EnergyEffectivenessRatio",
            category_id=obj.id,
            effective_date=date.today(),
            fuel_class__fuel_class="Gasoline"
        )

        if not ratio:
            return None

        return {
            "ratio": ratio.ratio,
            "effective_date": ratio.effective_date
        }