Kostenberechnung gefixt
This commit is contained in:
@@ -184,10 +184,10 @@ Domains jährlich: <span id="costDomain">0</span> €<br>
|
|||||||
<input id="os">
|
<input id="os">
|
||||||
|
|
||||||
<label>Kosten Monat</label>
|
<label>Kosten Monat</label>
|
||||||
<input id="kosten_monat">
|
<input id="kosten_monat" type="number" step="0.01">
|
||||||
|
|
||||||
<label>Kosten Jahr</label>
|
<label>Kosten Jahr</label>
|
||||||
<input id="kosten_jahr">
|
<input id="kosten_jahr" type="number" step="0.01">
|
||||||
|
|
||||||
<label>Providername</label>
|
<label>Providername</label>
|
||||||
<input id="providername">
|
<input id="providername">
|
||||||
|
|||||||
@@ -1,5 +1,42 @@
|
|||||||
window.resources = []
|
window.resources = []
|
||||||
|
|
||||||
|
function normalizeCostValue(value){
|
||||||
|
if(!value) return ""
|
||||||
|
|
||||||
|
return String(value).replace(",", ".")
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCostValue(value){
|
||||||
|
if(!Number.isFinite(value)) return ""
|
||||||
|
|
||||||
|
return value.toFixed(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupResourceCostSync(){
|
||||||
|
const monthInput = document.getElementById("kosten_monat")
|
||||||
|
const yearInput = document.getElementById("kosten_jahr")
|
||||||
|
|
||||||
|
if(!monthInput || !yearInput) return
|
||||||
|
|
||||||
|
monthInput.addEventListener("input", () => {
|
||||||
|
const month = parseFloat(normalizeCostValue(monthInput.value))
|
||||||
|
|
||||||
|
if(Number.isFinite(month)){
|
||||||
|
yearInput.value = formatCostValue(month * 12)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
yearInput.addEventListener("input", () => {
|
||||||
|
const year = parseFloat(normalizeCostValue(yearInput.value))
|
||||||
|
|
||||||
|
if(Number.isFinite(year)){
|
||||||
|
monthInput.value = formatCostValue(year / 12)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", setupResourceCostSync)
|
||||||
|
|
||||||
window.loadResources = async function(){
|
window.loadResources = async function(){
|
||||||
|
|
||||||
window.resources = await api(API + "/resources/active")
|
window.resources = await api(API + "/resources/active")
|
||||||
@@ -86,11 +123,16 @@ window.saveResource = async function(){
|
|||||||
const id = document.getElementById("resource_id").value
|
const id = document.getElementById("resource_id").value
|
||||||
const field = id => document.getElementById(id).value
|
const field = id => document.getElementById(id).value
|
||||||
|
|
||||||
let kostenMonat=document.getElementById("kosten_monat").value
|
let kostenMonat=normalizeCostValue(document.getElementById("kosten_monat").value)
|
||||||
let kostenJahr=document.getElementById("kosten_jahr").value
|
let kostenJahr=normalizeCostValue(document.getElementById("kosten_jahr").value)
|
||||||
|
|
||||||
if(kostenMonat) kostenMonat=kostenMonat.replace(",",".")
|
if(kostenMonat && !kostenJahr){
|
||||||
if(kostenJahr) kostenJahr=kostenJahr.replace(",",".")
|
kostenJahr = formatCostValue(parseFloat(kostenMonat) * 12)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(kostenJahr && !kostenMonat){
|
||||||
|
kostenMonat = formatCostValue(parseFloat(kostenJahr) / 12)
|
||||||
|
}
|
||||||
|
|
||||||
const data={
|
const data={
|
||||||
name: field("name"),
|
name: field("name"),
|
||||||
|
|||||||
Reference in New Issue
Block a user