Untitled
unknown
plain_text
3 years ago
7.0 kB
2
Indexable
let specialseason; let scdw; let grupo; let num_days; let num_cond; let num_cad; let gps; let aero_entrega; let aero_devolucao; let total_days; let total_insurance; let total_drivers; let total_airport_ent; let total_airport_dev; let total_gps; let total_chairs; let total_without_airport_with_tax; function setup() { createCanvas(600, 500); specialseason = createCheckbox("special season", false) specialseason.changed(checkboxSS) createElement("h5", "grupo") grupo = createInput("") grupo.input(grupoChanged) createElement("h5", "num dias") num_days = createInput("") num_days.input(numDaysChanged) scdw = createCheckbox("scdw", false) scdw.changed(checkboxSCDW) aero_entrega = createCheckbox("entrega aeroporto", false) aero_entrega.changed(checkboxAeroEntrega) aero_devolucao = createCheckbox("devolucao aeroporto", false) aero_devolucao.changed(checkboxAeroDevolucao) createElement("h5", "num condutores extra") num_cond = createInput("") num_cond.input(numCondutoresChanged) createElement("h5", "num cadeiras") num_cad = createInput("") num_cad.input(numCadChanged) gps = createCheckbox("gps", false) gps.changed(checkboxGPS) } function checkboxSCDW() { calculate() } function checkboxSS() { //console.log(specialseason.checked()) calculate() } function numDaysChanged() { //console.log(this.value()) calculate() } function numCondutoresChanged() { calculate() } function numCadChanged() { calculate() } function grupoChanged() { calculate() } function checkboxGPS() { calculate() } function checkboxAeroEntrega() { calculate() } function checkboxAeroDevolucao() { calculate() } function calculate() { } function draw() { background(220); fill(0); textSize(16); text(`Special Season: ${specialseason.checked() ? "Yes" : "No"}`, 10, 30); text(`Group: ${grupo.value()}`, 10, 60); text(`Num. days: ${num_days.value()}`, 10, 90); text(`Insurance: ${scdw.checked() ? "SCDW" : "Mandatory"}`, 10, 120); text(`Airport delivery: ${aero_entrega.checked() ? "Yes" : "No"}`, 10, 150); text(`Airport pickup: ${aero_devolucao.checked() ? "Yes" : "No"}`, 10, 180); text(`Num. drivers: ${num_cond.value()}`, 10, 210); text(`Num. chairs: ${num_cad.value()}`, 10, 240); text(`GPS: ${gps.checked() ? "Yes" : "No"}`, 10, 270); price_day = 0 if (!specialseason.checked()) { if(grupo.value().toLowerCase() === "a") { let nd = num_days.value() if (nd <= 2) price_day = 17.78 else if (nd <= 6) price_day = 14.91 else price_day = 13.28 } else if(grupo.value().toLowerCase() === "b") { let nd = num_days.value() if (nd <= 2) price_day = 22.33 else if (nd <= 6) price_day = 19.22 else price_day = 17.58 } else if(grupo.value().toLowerCase() === "c") { let nd = num_days.value() if (nd <= 2) price_day = 27.48 else if (nd <= 6) price_day = 25.82 else price_day = 21.76 } else if(grupo.value().toLowerCase() === "d") { let nd = num_days.value() if (nd <= 2) price_day = 67.46 else if (nd <= 6) price_day = 63.36 else price_day = 58.85 } else if(grupo.value().toLowerCase() === "m") { let nd = num_days.value() if (nd <= 2) price_day = 22.33 else if (nd <= 6) price_day = 19.22 else price_day = 17.58 } } else { if(grupo.value().toLowerCase() === "a") { let nd = num_days.value() if (nd <= 2) price_day = 29.34 else if (nd <= 6) price_day = 27.66 else price_day = 24.30 } else if(grupo.value().toLowerCase() === "b") { let nd = num_days.value() if (nd <= 2) price_day = 43.85 else if (nd <= 6) price_day = 39.14 else price_day = 34.96 } else if(grupo.value().toLowerCase() === "c") { let nd = num_days.value() if (nd <= 2) price_day = 53.28 else if (nd <= 6) price_day = 48.20 else price_day = 44.10 } else if(grupo.value().toLowerCase() === "d") { let nd = num_days.value() if (nd <= 2) price_day = 87.25 else if (nd <= 6) price_day = 83.16 else price_day = 79.06 } else if(grupo.value().toLowerCase() === "m") { let nd = num_days.value() if (nd <= 2) price_day = 43.85 else if (nd <= 6) price_day = 39.14 else price_day = 34.96 } } total_days = (num_days.value() * price_day) insurance_day = 0 if (specialseason.checked()) { if (grupo.value().toLowerCase() === "d") { if (scdw.checked()) insurance_day = 21.23 else insurance_day = 8.61 } else { if (scdw.checked()) insurance_day = 17.13 else insurance_day = 8.61 } } else { if (grupo.value().toLowerCase() === "d") { if (scdw.checked()) insurance_day = 17.13 else insurance_day = 8.61 } else { if (scdw.checked()) insurance_day = 15.08 else insurance_day = 8.61 } } total_insurance = (num_days.value() * insurance_day) total_airport_ent = aero_entrega.checked() ? 12.95 : 0 total_airport_dev = aero_devolucao.checked() ? 12.95 : 0 total_drivers = num_cond.value() * num_days.value() * 8.61 total_chairs = num_cad.value() * num_days.value() * 2.87 total_gps = gps.checked() ? num_days.value() * 4.10 : 0 total_no_tax = total_days + total_insurance + total_airport_ent + total_airport_dev + total_drivers + total_chairs + total_gps total_tax = total_no_tax * 0.22 total_with_tax = total_no_tax + total_tax total_without_airport_with_tax = ((total_no_tax - total_airport_ent - total_airport_dev) * 1.22) / num_days.value() text(`${total_days.toFixed(2)}`, 300, 90); text(`${total_insurance.toFixed(2)}`, 300, 120); text(`${total_airport_ent.toFixed(2)}`, 300, 150); text(`${total_airport_dev.toFixed(2)}`, 300, 180); text(`${total_drivers.toFixed(2)}`, 300, 210); text(`${total_chairs.toFixed(2)}`, 300, 240); text(`${total_gps.toFixed(2)}`, 300, 270); text(`Total before tax: ${total_no_tax.toFixed(2)}`, 300, 300); text(`Tax: ${total_tax.toFixed(2)}`, 300, 330); text(`Total after tax: ${total_with_tax.toFixed(2)}`, 300, 360); text(`\n\nPrice per day\n(without airport and with VAT): ${total_without_airport_with_tax.toFixed(2)}`, 300, 360); }
Editor is loading...