Skip to content

Commit

Permalink
Added selection of “own district” for value added calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
JetteThiele committed Nov 26, 2024
1 parent 94ba16d commit aab6d3e
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 56 deletions.
18 changes: 11 additions & 7 deletions slapp/kommWertTool/cal_mun_rev.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def create_echarts_data_srbb(wind_sr_bb_yearly, pv_sr_bb_yearly, apv_sr_bb_yearl
]
}
return(echarts_data_sr, f"wind_solar_euro.json")
def create_echarts_data_gesamteinnahmen(trade_tax_plant, eeg_income, sr_bb_income,
def create_echarts_data_total_mun_income(trade_tax_plant, eeg_income, sr_bb_income,
area_costs_total, area_gewst_total, area_est_total, sum_wea_plot, sum_agri_pv_plot, sum_ff_pv_plot):
legend_data = []
series_data = []
Expand Down Expand Up @@ -217,15 +217,17 @@ def add_series(name, data, yAxisIndex=0):
"name": "Einnahmen",
"axisLabel": {
"formatter": "{value}".replace(",", ".")
}
},
"splitNumber": 5
},
{
"type": "value",
"name": "Gesamteinnahmen",
"axisLabel": {
"formatter": "{value}".replace(",", ".")
},
"position": "right"
"position": "right",
"splitNumber": 5
}
],
"series": [
Expand Down Expand Up @@ -374,7 +376,8 @@ def extend_list(lst):
mun_key_value = int(form_data.get('mun_key_value', 0.003))
apvv_mw_ha = 0.35
apvh_mw_ha = 0.65
choosen_mun = int(form_data.get('choosen_mun', 0))
choosen_mun = form_data.get('choosen_mun', 0)
check_county = form_data.get('check_county', 'check_county_bb')
# standard levy rate if None is given
if mun_key_value == 0:
mun_key_value = 0.3
Expand Down Expand Up @@ -933,7 +936,7 @@ def max_annual_sum(trade_tax_results, scenario_name_for_sum):
echart_eeg = create_echarts_data_eeg(wind_eeg_yearly, pv_eeg_yearly, apv_eeg_yearly)
echart_srbb = create_echarts_data_srbb(wind_sr_bb_yearly, pv_sr_bb_yearly, apv_sr_bb_yearly)

echart_total_income = create_echarts_data_gesamteinnahmen(trade_tax_plant, eeg_income, sr_bb_income,
echart_total_income = create_echarts_data_total_mun_income(trade_tax_plant, eeg_income, sr_bb_income,
area_costs_total.tolist(), area_gewst_total.tolist(),
area_est_total.tolist(), sum_wea_plot, sum_agri_pv_plot, sum_ff_pv_plot)

Expand Down Expand Up @@ -969,7 +972,6 @@ def format_numbers(value):
sum_wea = format_numbers(sum_wea)
sum_ff_pv = format_numbers(sum_ff_pv)
sum_agri_pv = format_numbers(sum_agri_pv)
choosen_mun = format_numbers(choosen_mun)


results.update({"wind_eeg_yearly": wind_eeg_yearly,
Expand Down Expand Up @@ -997,6 +999,7 @@ def format_numbers(value):
'sum_ff_pv': sum_ff_pv,
'sum_agri_pv': sum_agri_pv,
'choosen_mun': choosen_mun,
'check_county':check_county,
'echart_area_lease_income': echart_area_lease_income,
'echart_eeg': echart_eeg,
'echart_wind_solar_euro': echart_srbb,
Expand Down Expand Up @@ -1025,6 +1028,7 @@ def format_numbers(value):
'apv_hor_p_max': '600',
'area_ownertype': {},
'levy_rate': '435',
'choosen_mun': '1'
'choosen_mun': '1',
'check_county': 'check_county_bb'
}
main(form_data)
118 changes: 81 additions & 37 deletions slapp/kommWertTool/templates/added_value_calc.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,28 @@ <h1 class="mt-3">Wertschöpfung</h1>

<option value="{{ municipality.id }}" data-name="{{ municipality.name }}">{{ municipality.name }}</option>
{% endfor %}
</select> </div></div>
<option value="own_county" data-name="own_county">Eigener Landkreis</option>
</select>

</div>
<div id="check_county" class="col-md-6">
<p>
<b>In welchem Bundesland befindet sich der Landkreis:</b>
</p>
<div class="row"> <div class="col-md-6">
<input class="form-check-input" id="check_county_bb" name="check_county" data-name="check_county_bb" value="check_county_bb" type="radio">
<label class="form-check-label" for="check_county_bb">
Brandenburg
</label>
</div>
<div class="col-md-6">
<input class="form-check-input" id="check_county_sh" data-name="check_county_sh" value="check_county_sh" name="check_county" type="radio">
<label class="form-check-label" for="check_county_sh">
Schleswig-Holstein
</label></div>
</div></div>

</div>
<div class="row mt-2">
<div class="col-md-6"> <label for="levy_rate">
Hebesatz der Gemeinde (<i>optional</i>):
Expand Down Expand Up @@ -671,50 +692,73 @@ <h6 class="mb-0"><b>Optional</b></h6>
toggleRemoveButton('apvv');
toggleRemoveButton('apvh');
});

document.addEventListener('DOMContentLoaded', function() {
const dropdown = document.getElementById('choosen_mun');
const inputField = document.getElementById('levy_rate');

// Objekt zur Zuordnung von Dropdown-Werten zu spezifischen Zahlen
const valueMap = {
'0': 450,
'4': 300,
'5': 350,
'6': 300,
'7': 320
};

dropdown.addEventListener('change', function() {
const selectedValue = this.value;
if (selectedValue in valueMap) {
inputField.value = valueMap[selectedValue];
} else {
inputField.value = ''; // Leert das Feld, wenn keine gültige Option ausgewählt ist
}
});
// Adds levy rate of the chosen municipality to the input field
const selectElement = document.getElementById('choosen_mun');
const inputField = document.getElementById('levy_rate');
const valueMap = {
'0': 450,
'4': 300,
'5': 350,
'6': 300,
'7': 320,
'own_county': ''
};

// Event Listener für das Dropdown-Menü
selectElement.addEventListener('change', function() {
const selectedValue = this.value;
if (selectedValue in valueMap) {
inputField.value = valueMap[selectedValue];
} else {
inputField.value = '';
}

// Überprüfen der Sichtbarkeit nach Auswahländerung
checkMunicipality();
});

// Hide Wind-Euro if mun is not in BB
var selectElement = document.getElementById('choosen_mun');
var windEuroShareDiv = document.querySelector('.col-md-6 label[for="wind_euro_share"]').parentElement;
// Hides wind/solar-euro if municipality is not in BB + displays county selection when own_county is chosen
function checkMunicipality() {
var windEuroShareDiv = document.querySelector('.col-md-6 label[for="wind_euro_share"]').parentElement;
var countyCheckDiv = document.getElementById('check_county');

function checkMunicipality() {
var selectedOption = selectElement.options[selectElement.selectedIndex];
var municipalityName = selectedOption.getAttribute('data-name');
var selectedOption = selectElement.options[selectElement.selectedIndex];
var municipalityName = selectedOption.getAttribute('data-name');

if (municipalityName === 'Kiel') {
windEuroShareDiv.style.display = 'none';
} else {
windEuroShareDiv.style.display = 'block';
var selectedRadio = document.querySelector('input[name="check_county"]:checked');
var countyName = selectedRadio ? selectedRadio.getAttribute('data-name') : null;

if (municipalityName === 'Kiel') {
windEuroShareDiv.style.display = 'none';
countyCheckDiv.style.display = 'none';
} else if (municipalityName === 'own_county') {
countyCheckDiv.style.display = 'block';
if (countyName === 'check_county_sh') {
windEuroShareDiv.style.display = 'none';
} else {
windEuroShareDiv.style.display = 'block';
}
} else {
windEuroShareDiv.style.display = 'block';
countyCheckDiv.style.display = 'none';
}
}
}

// Überprüfen des ausgewählten Elements beim Laden der Seite
checkMunicipality();
// Event Listener für Radiobuttons
document.querySelectorAll('input[name="check_county"]').forEach(function(radio) {
radio.addEventListener('change', checkMunicipality);
});

// Überprüfen des ausgewählten Elements bei Änderungen
selectElement.addEventListener('change', checkMunicipality);
});
// Überprüfen des ausgewählten Elements beim Laden der Seite
checkMunicipality();
var selectedRadio = document.querySelector('input[name="check_county"]:checked');
var countyName = selectedRadio ? selectedRadio.value : null; // Hier wird der Wert abgerufen
console.log("Selected County Name:", countyName); // Debugging-Ausgabe


});

</script>
{% endblock inline_javascript %}
26 changes: 14 additions & 12 deletions slapp/kommWertTool/templates/added_value_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ <h3 class="smallHeadline">EEG-Beteiligung (jährlich)</h3>
</div>
</div>
</div>
<hr>
{% if results.choosen_mun != "0,00" %}
{% if results.choosen_mun != "0" and results.check_county != "check_county_sh" %}
<hr>
<div class="row">
<div class="col-md-6 d-flex align-items-center">
<div id="wind_solar_euro_loader" class="loader"> </div>
<div id="wind_solar_euro_chart" style="width: 100%; height: 400px;"></div>
</div>
<div class="col-md-6">
<h3 class="smallHeadline">Wind- & Solar-Euro (jährlich)</h3>
<p>Um die Akzeptanz von WEA und PV-Anlagen zu steigern, hat der Landtag Brandenburg zwei
<p>{{ results.choosen_mun }} {{ results.check_county }} Um die Akzeptanz von WEA und PV-Anlagen zu steigern, hat der Landtag Brandenburg zwei
Sonderregelungen verabschiedet. Ab 2025 müssen Betreibende von FF-PV- und APV-Anlagen 2.000,00 Euro
pro MW und Jahr an die jeweilige Standortgemeinde zahlen. Ab 2026 zahlen Anlagenbetreibende von WEA 5.000,00 Euro
pro installierten MW. Beteiligt werden alle Gemeinden, die sich in einem
Expand Down Expand Up @@ -103,7 +103,7 @@ <h3 class="smallHeadline">Wind- & Solar-Euro (jährlich)</h3>
{% if results.wea_area_income != "0,00" or results.pv_area_income != "0,00" or results.apv_area_income != "0,00" or results.lease_est_income_wea != "0,00" or results.lease_est_income_pv != "0,00" or results.lease_est_income_apv != "0,00" or results.lease_trade_tax_wea != "0,00" or results.lease_trade_tax_pv != "0,00" or results.lease_trade_tax_apv != "0,00" %}
<hr>
<div class="row">
<div class="col-md-6">
<div class="col-md-6 d-flex align-items-center">
<div id="area_lease_income_loader" class="loader"> </div>
<div id="area_lease_income_chart" style="width: 100%; height: 400px;"></div>
</div>
Expand Down Expand Up @@ -400,19 +400,21 @@ <h2 class="rowHeader">Gesamteinnahmen über 25 Jahre</h2>
{
type: 'value',
name: Array.isArray(chartData.yAxis) ? chartData.yAxis[0]?.name : chartData.yAxis?.name || '',
axisLabel: { formatter: formatNumber }
axisLabel: { formatter: formatNumber },
},
{
type: 'value',
name: Array.isArray(chartData.yAxis) ? chartData.yAxis[1]?.name : '',
axisLabel: { formatter: formatNumber },
position: 'right'
}
] : {
type: 'value',
name: chartData.yAxis?.name || '',
axisLabel: { formatter: formatNumber }
},
position: 'right',
}
] : [
{
type: 'value',
name: chartData.yAxis?.name || '',
axisLabel: { formatter: formatNumber },
}
],
series: Array.isArray(chartData.series) ? chartData.series.map(series => ({
...series,
data: Array.isArray(series.data) ? series.data.map(value => parseFloat(value) || 0) : []
Expand Down

0 comments on commit aab6d3e

Please sign in to comment.