function Empleado(nombre, sueldo) {
this.nombre = nombre;
this.sueldo = sueldo;
this.empresa = "Netmind";
this.departamento = "";
this.sueldoNeto = function () {
return this.sueldo * (1-this.irpf());
};
this.irpf = function () {
if (this.sueldo < 1500) {
return .2;
}
if (this.sueldo >= 1500 && this.sueldo < 3000) {
return .3;
}
return .4;
};
this.neto=function(){
var sueldo=this.sueldo;
var irpf=this.irpf();
var neto=sueldo-sueldo*irpf;
return neto;
};
}
function Empresa(nombre) {
this.nombre = nombre;
this.jefe = new Empleado("Jefe", 3000);
this.empleados = [];
for (var i = 0; i < 10; i++) {
this.empleados.push(new Empleado("Empleado" + i, 1400 + i * 100));
}
this.comerciales = [];
for (var i = 0; i < 3; i++) {
var e = new Empleado("Comercial" + i, 1400 + i * 100);
e.departamento = "Comercial";
this.comerciales.push(e);
}
}
function Holding(emp1, emp2) {
this.empresas = [emp1, emp2];
}
var netmind = new Empresa("Netmind");
var activity = new Empresa("Activity");
var conglomerado = new Holding(netmind, activity);
var ana = new Empleado("Ana Pérez", 1500);
var juan = new Empleado("Juan Pi", 1400);
var empleados = [];
for (var i = 0; i < 10; i++) {
empleados.push(new Empleado("Empleado" + i, 1400 + i * 100));
}
String.prototype.oracion = function () {
return this.valueOf().charAt(0).toUpperCase() + this.valueOf().slice(1).toLowerCase();
}
function Producto(nombre,precio){
this.nombre=nombre;
this.precio=precio;
this.iva=.21;
this.referencia=("0000" + Math.floor(Math.random()*10000)).slice(-4);
this.pvp=function(){
return this.precio*(1+this.iva);
}
this.pvpConDescuento=function(descuento){
return this.pvp()*(1-descuento/100);
}
}
var tornillo = new Producto("tornillo",100);