Files
HerramientaCASA/bdHerramientaCACOA/HerramientaUrban/URBANCostesProduccion.cs
2025-09-24 14:28:29 +02:00

123 lines
5.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using bdHerramientaCACOA.extensiones;
using static bdHerramientaCACOA.CASA;
namespace bdHerramientaCACOA.HerramientaURBAN
{
public partial class URBAN
{
public class URBANCostesProduccion
{
public bool EsCalculado { get; set; } = true;
public double porcentaje { get; set; } = 2.5;
public List<CosteVariable> ListaCostesVariables { get; set; } = new List<CosteVariable>();
public double CostesVariables { get; set; } = 0;
public double TotalCostesVariables { get; set; } = 0;
public double TotalCostes { get; set; } = 0;
public double CoeficienteCostesExternalizacion { get; set; } = 15;
public double CosteHoraExternalizacion { get; set; } = 0;
//h
public double HorasTrabajoProfesional { get; set; } = 0;
public double PlazoPresentacionDocumentos { get; set; } = 6;
public double HorasEnPlazo { get; set; } = 0;
public double NumHorasMinimoExt { get; set; } = 0;
//€
public double CostesProduccionTrabProf { get; set; } = 0;
public double Beneficio { get; set; } = 0;
public double PrecioTrabajoProfesional { get; set; } = 0;
}
//Funciones Costes Produccion
public void InsertarCostesVariables(CosteVariable cv)
{
CostesProduccion.ListaCostesVariables.Add(cv);
CalcularCostesProduccion();
}
public void ActualizarCostesVariables(CosteVariable cv)
{
int indice = CostesProduccion.ListaCostesVariables.ToList().IndexOf(cv);
CostesProduccion.ListaCostesVariables[indice] = cv;
CalcularCostesProduccion();
}
public void EliminarCostesVariables(CosteVariable cv)
{
CostesProduccion.ListaCostesVariables.Remove(cv);
CalcularCostesProduccion();
}
public double CalcularCostesTotales()
{
return CostesProduccion.ListaCostesVariables.Sum(x => x.Coste);
}
public void CalcularCostesProduccion()
{
if (CostesProduccion.EsCalculado)
{
double chtp = CalcularHorasTotalesProduccion();
if (chtp == 0)
{
CostesProduccion.CostesVariables = 0;
}
else
{
CostesProduccion.CostesVariables = Math.Round(CalcularCostesTotales() / CalcularHorasTotalesProduccion(), 2);
}
}
else
{
CostesProduccion.CostesVariables = ((DespachoProfesional.CostesDirectos + DespachoProfesional.TasaCostesIndirectos) * (CostesProduccion.porcentaje / 100)).DosDecimales();
}
CostesProduccion.TotalCostesVariables = CalcularCostesTotales();
CostesProduccion.TotalCostes = (DespachoProfesional.CostesDirectos + DespachoProfesional.TasaCostesIndirectos + CostesProduccion.CostesVariables).DosDecimales();
CostesProduccion.CosteHoraExternalizacion = Math.Round(CostesProduccion.TotalCostes * (1 + CostesProduccion.CoeficienteCostesExternalizacion / 100), 2, MidpointRounding.AwayFromZero);
//H
if (TrabajoProfesional.horasTrabProfesional<40) {
CostesProduccion.HorasTrabajoProfesional = 40;
}
else
{
double totalEncargo = TrabajoProfesional.FasesTrabajoProfesional.Sum(x => x.Porcentaje);
CostesProduccion.HorasTrabajoProfesional = (TrabajoProfesional.horasTrabProfesional * (totalEncargo / 100)).DosDecimales();
}
/*
CostesProduccion.HorasEnPlazo = (DespachoProfesional.HorasTotalesProduccion * CostesProduccion.PlazoPresentacionDocumentos / 12).DosDecimales();
if (CostesProduccion.HorasEnPlazo >= CostesProduccion.HorasTrabajoProfesional)
{
CostesProduccion.NumHorasMinimoExt = 0;
}
else
{
CostesProduccion.NumHorasMinimoExt = (CostesProduccion.HorasTrabajoProfesional - CostesProduccion.HorasEnPlazo).DosDecimales();
}*/
CostesProduccion.HorasEnPlazo = (DespachoProfesional.HorasTotalesProduccion * CostesProduccion.PlazoPresentacionDocumentos / 12).DosDecimales();
if (CostesProduccion.HorasEnPlazo > TrabajoProfesional.horasTrabProfesional) {
CostesProduccion.HorasEnPlazo = TrabajoProfesional.horasTrabProfesional;
}
CostesProduccion.NumHorasMinimoExt = (CostesProduccion.HorasEnPlazo >= TrabajoProfesional.horasTrabProfesional) ?
0 :
Math.Round(TrabajoProfesional.horasTrabProfesional - CostesProduccion.HorasEnPlazo, 2, MidpointRounding.AwayFromZero);
//€
if (CostesProduccion.NumHorasMinimoExt == 0)
{
CostesProduccion.CostesProduccionTrabProf = (CostesProduccion.HorasTrabajoProfesional * CostesProduccion.TotalCostes).DosDecimales();
}
else
{
CostesProduccion.CostesProduccionTrabProf = ((CostesProduccion.HorasEnPlazo * CostesProduccion.TotalCostes) + (CostesProduccion.NumHorasMinimoExt * CostesProduccion.CosteHoraExternalizacion)).DosDecimales();
}
CostesProduccion.PrecioTrabajoProfesional = (CostesProduccion.CostesProduccionTrabProf * (1+(CostesProduccion.Beneficio/100))).DosDecimales();
}
}
}