def update(self, instance, validated_data): request = self.context.get('request') if 'diesel_carbon_intensity' in validated_data: fuel_class_id = FuelClass.objects.get(fuel_class="Diesel").id CreditCalculationService.update( compliance_period_id=instance.id, density=validated_data['diesel_carbon_intensity'], effective_date=validated_data['diesel_effective_date'], fuel_class_id=fuel_class_id, model_name="CarbonIntensityLimit", update_user=request.user) if 'gasoline_carbon_intensity' in validated_data: fuel_class_id = FuelClass.objects.get(fuel_class="Gasoline").id CreditCalculationService.update( compliance_period_id=instance.id, density=validated_data['gasoline_carbon_intensity'], effective_date=validated_data['gasoline_effective_date'], fuel_class_id=fuel_class_id, model_name="CarbonIntensityLimit", update_user=request.user) return validated_data
def update(self, instance, validated_data): request = self.context.get('request') if 'diesel_ratio' in validated_data: fuel_class_id = FuelClass.objects.get(fuel_class="Diesel").id CreditCalculationService.update( category_id=instance.id, effective_date=validated_data['diesel_effective_date'], fuel_class_id=fuel_class_id, model_name="EnergyEffectivenessRatio", ratio=validated_data['diesel_ratio'], update_user=request.user ) if 'gasoline_ratio' in validated_data: fuel_class_id = FuelClass.objects.get(fuel_class="Gasoline").id CreditCalculationService.update( category_id=instance.id, effective_date=validated_data['gasoline_effective_date'], fuel_class_id=fuel_class_id, model_name="EnergyEffectivenessRatio", ratio=validated_data['gasoline_ratio'], update_user=request.user ) return validated_data
def update(self, instance, validated_data): request = self.context.get('request') CreditCalculationService.update( category_id=instance.id, effective_date=validated_data['effective_date'], model_name="EnergyDensity", density=validated_data['density'], update_user=request.user) return validated_data