Exemplo n.º 1
0
        public void SaveBudget(ProjectDto project, List<TaskDto> taskList)
        {
            if (project != null)
            {
                var code = Convert.ToDouble(project.Code);
                var prePresupuestos = Asgard._Foreing.PRE_PRESUPUESTOS.Where(x => x.PRE_NUMERO.Equals(code)).SingleOrDefault();

                if (prePresupuestos != null)
                {// Edit
                    Map(project, prePresupuestos, taskList);
                }
                else
                {// Add
                    if (project.Code != null)
                    {
                        prePresupuestos = new PRE_PRESUPUESTOS();
                        Map(project, prePresupuestos, taskList);
                        Asgard._Foreing.PRE_PRESUPUESTOS.AddObject(prePresupuestos);
                    }
                }
                Asgard._Foreing.SaveChanges();
            }
        }
 /// <summary>
 /// Create a new PRE_PRESUPUESTOS object.
 /// </summary>
 /// <param name="cIA_CODIGO">Initial value of the CIA_CODIGO property.</param>
 /// <param name="pRE_NUMERO">Initial value of the PRE_NUMERO property.</param>
 /// <param name="cLI_CLIENTE">Initial value of the CLI_CLIENTE property.</param>
 /// <param name="sVR_CODIGO">Initial value of the SVR_CODIGO property.</param>
 /// <param name="vEN_VENDEDOR">Initial value of the VEN_VENDEDOR property.</param>
 /// <param name="pRE_NOMBREPROYECTO">Initial value of the PRE_NOMBREPROYECTO property.</param>
 /// <param name="pRE_SUBTOTAL_H">Initial value of the PRE_SUBTOTAL_H property.</param>
 /// <param name="pRE_IMPREVISTOS">Initial value of the PRE_IMPREVISTOS property.</param>
 /// <param name="pRE_UTILIDAD">Initial value of the PRE_UTILIDAD property.</param>
 /// <param name="pRE_GARANTIA">Initial value of the PRE_GARANTIA property.</param>
 /// <param name="pRE_TOTALMETROS">Initial value of the PRE_TOTALMETROS property.</param>
 /// <param name="pRE_TOTALSERVICIO">Initial value of the PRE_TOTALSERVICIO property.</param>
 /// <param name="pRE_COSTOXMETRO">Initial value of the PRE_COSTOXMETRO property.</param>
 /// <param name="pRE_APLICADO">Initial value of the PRE_APLICADO property.</param>
 /// <param name="pRE_PORC_IMPREVISTOS">Initial value of the PRE_PORC_IMPREVISTOS property.</param>
 /// <param name="pRE_PORC_UTILIDAD">Initial value of the PRE_PORC_UTILIDAD property.</param>
 /// <param name="pRE_PORC_GARANTIA">Initial value of the PRE_PORC_GARANTIA property.</param>
 /// <param name="pRE_SUBTOTAL_I">Initial value of the PRE_SUBTOTAL_I property.</param>
 /// <param name="pRE_SUBTOTAL_J">Initial value of the PRE_SUBTOTAL_J property.</param>
 /// <param name="pRE_SUBTOTAL_K">Initial value of the PRE_SUBTOTAL_K property.</param>
 /// <param name="pRE_PORC_MUP">Initial value of the PRE_PORC_MUP property.</param>
 /// <param name="pRE_MUP">Initial value of the PRE_MUP property.</param>
 /// <param name="pRE_PORC_UTIL_GNRL">Initial value of the PRE_PORC_UTIL_GNRL property.</param>
 /// <param name="pRE_UTILIDAD_GNRL">Initial value of the PRE_UTILIDAD_GNRL property.</param>
 /// <param name="pRE_TOTAL_GNRL">Initial value of the PRE_TOTAL_GNRL property.</param>
 public static PRE_PRESUPUESTOS CreatePRE_PRESUPUESTOS(global::System.String cIA_CODIGO, global::System.Double pRE_NUMERO, global::System.String cLI_CLIENTE, global::System.String sVR_CODIGO, global::System.String vEN_VENDEDOR, global::System.String pRE_NOMBREPROYECTO, global::System.Double pRE_SUBTOTAL_H, global::System.Double pRE_IMPREVISTOS, global::System.Double pRE_UTILIDAD, global::System.Double pRE_GARANTIA, global::System.Double pRE_TOTALMETROS, global::System.Double pRE_TOTALSERVICIO, global::System.Double pRE_COSTOXMETRO, global::System.Int32 pRE_APLICADO, global::System.Double pRE_PORC_IMPREVISTOS, global::System.Double pRE_PORC_UTILIDAD, global::System.Double pRE_PORC_GARANTIA, global::System.Double pRE_SUBTOTAL_I, global::System.Double pRE_SUBTOTAL_J, global::System.Double pRE_SUBTOTAL_K, global::System.Double pRE_PORC_MUP, global::System.Double pRE_MUP, global::System.Double pRE_PORC_UTIL_GNRL, global::System.Double pRE_UTILIDAD_GNRL, global::System.Double pRE_TOTAL_GNRL)
 {
     PRE_PRESUPUESTOS pRE_PRESUPUESTOS = new PRE_PRESUPUESTOS();
     pRE_PRESUPUESTOS.CIA_CODIGO = cIA_CODIGO;
     pRE_PRESUPUESTOS.PRE_NUMERO = pRE_NUMERO;
     pRE_PRESUPUESTOS.CLI_CLIENTE = cLI_CLIENTE;
     pRE_PRESUPUESTOS.SVR_CODIGO = sVR_CODIGO;
     pRE_PRESUPUESTOS.VEN_VENDEDOR = vEN_VENDEDOR;
     pRE_PRESUPUESTOS.PRE_NOMBREPROYECTO = pRE_NOMBREPROYECTO;
     pRE_PRESUPUESTOS.PRE_SUBTOTAL_H = pRE_SUBTOTAL_H;
     pRE_PRESUPUESTOS.PRE_IMPREVISTOS = pRE_IMPREVISTOS;
     pRE_PRESUPUESTOS.PRE_UTILIDAD = pRE_UTILIDAD;
     pRE_PRESUPUESTOS.PRE_GARANTIA = pRE_GARANTIA;
     pRE_PRESUPUESTOS.PRE_TOTALMETROS = pRE_TOTALMETROS;
     pRE_PRESUPUESTOS.PRE_TOTALSERVICIO = pRE_TOTALSERVICIO;
     pRE_PRESUPUESTOS.PRE_COSTOXMETRO = pRE_COSTOXMETRO;
     pRE_PRESUPUESTOS.PRE_APLICADO = pRE_APLICADO;
     pRE_PRESUPUESTOS.PRE_PORC_IMPREVISTOS = pRE_PORC_IMPREVISTOS;
     pRE_PRESUPUESTOS.PRE_PORC_UTILIDAD = pRE_PORC_UTILIDAD;
     pRE_PRESUPUESTOS.PRE_PORC_GARANTIA = pRE_PORC_GARANTIA;
     pRE_PRESUPUESTOS.PRE_SUBTOTAL_I = pRE_SUBTOTAL_I;
     pRE_PRESUPUESTOS.PRE_SUBTOTAL_J = pRE_SUBTOTAL_J;
     pRE_PRESUPUESTOS.PRE_SUBTOTAL_K = pRE_SUBTOTAL_K;
     pRE_PRESUPUESTOS.PRE_PORC_MUP = pRE_PORC_MUP;
     pRE_PRESUPUESTOS.PRE_MUP = pRE_MUP;
     pRE_PRESUPUESTOS.PRE_PORC_UTIL_GNRL = pRE_PORC_UTIL_GNRL;
     pRE_PRESUPUESTOS.PRE_UTILIDAD_GNRL = pRE_UTILIDAD_GNRL;
     pRE_PRESUPUESTOS.PRE_TOTAL_GNRL = pRE_TOTAL_GNRL;
     return pRE_PRESUPUESTOS;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the PRE_PRESUPUESTOS EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPRE_PRESUPUESTOS(PRE_PRESUPUESTOS pRE_PRESUPUESTOS)
 {
     base.AddObject("PRE_PRESUPUESTOS", pRE_PRESUPUESTOS);
 }
Exemplo n.º 4
0
        private void Map(ProjectDto source, PRE_PRESUPUESTOS destination, IEnumerable<TaskDto> taskList)
        {
            #region Map
            destination.CIA_CODIGO = "01";
            destination.PRE_NUMERO = Convert.ToDouble(source.Code);
            destination.CLI_CLIENTE = source.BudgetRequest.Customer.BindCustomer.AlienId;
            destination.SVR_CODIGO = "00";                         // Necesario por ser llave foranea {No existe en SGP}{NO APLICA}
            destination.PRE_FECHA = DateTime.Today;
            destination.VEN_VENDEDOR = "SGP";                        //Se utiliza un estandar, en este caso es el sitema SGP
            destination.PRE_NOMBREPROYECTO = source.Name;
            destination.PRE_OBSERVACIONES = source.Comments;
            destination.PRE_ACTIVIDADES = "GENERADO MEDIANTE SGP";
            destination.PRE_TOTALMETROS = source.TotalMeters;

            destination.PRE_SUBTOTAL_H = 0.0;                      //{Pendiente}
            destination.PRE_SUBTOTAL_I = 0.0;                      //{Pendiente}
            destination.PRE_SUBTOTAL_J = 0.0;                      //{Pendiente}
            destination.PRE_APLICADO = 0;                        //{Pendiente}
            destination.PRE_PORC_UTILIDAD = 0.0;
            destination.PRE_UTILIDAD = 0.0;
            destination.PRE_PORC_MUP = 0.0;

            destination.PRE_SUBTOTAL_K = Convert.ToDouble(CalcSubtotal(source));
            destination.PRE_PORC_IMPREVISTOS = source.ContingenciesRate;
            destination.PRE_IMPREVISTOS = destination.PRE_SUBTOTAL_K * destination.PRE_PORC_IMPREVISTOS / 100;
            destination.PRE_PORC_GARANTIA = source.GuaranteeRate;
            destination.PRE_GARANTIA = destination.PRE_SUBTOTAL_K * destination.PRE_PORC_GARANTIA / 100;

            var other = destination.PRE_SUBTOTAL_K * source.OthersRate / 100; // + % Otros que no aparece en dialcom

            destination.PRE_TOTALSERVICIO = destination.PRE_SUBTOTAL_K + destination.PRE_IMPREVISTOS + destination.PRE_GARANTIA + other;
            destination.PRE_PORC_UTIL_GNRL = source.TotalUtilityRate;
            destination.PRE_UTILIDAD_GNRL = destination.PRE_TOTALSERVICIO * destination.PRE_PORC_UTIL_GNRL / 100;

            var discount = (destination.PRE_TOTALSERVICIO + destination.PRE_UTILIDAD_GNRL) * source.DiscountRate / 100;

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
            /**/
            destination.PRE_TOTAL_GNRL = destination.PRE_TOTALSERVICIO + destination.PRE_UTILIDAD_GNRL - discount;/**/
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////

            if (destination.PRE_TOTALMETROS <= 0)
                destination.PRE_COSTOXMETRO = 0;
            else
                destination.PRE_COSTOXMETRO = destination.PRE_TOTAL_GNRL / destination.PRE_TOTALMETROS;

            destination.FAM_Codigo = source.BudgetRequest.Family.Id;        // Necesario por ser llave foranea
            destination.TIP_Codigo = 33;                                    // Necesario por ser llave foranea {No existe en SGP}{Otros}
            destination.SUB_Codigo = 999;                                   // Necesario por ser llave foranea {No existe en SGP}{Ninguno}
            destination.USR_Usuario_Inclusion = "SGP";
            destination.USR_Fecha_Inclusion = DateTime.Today;
            destination.USR_Usuario_Modificacion = "SGP";
            destination.USR_Fecha_Modificacion = DateTime.Today;
            #endregion

            GetBudgetDetail(taskList, destination.PRE_DETALLE);
            GetBudgetTask(taskList, destination.TaskByBudgets);
            GetTotalDetail(destination.PRE_TOTALESDETALLE_X_HOJAPRESUPUESTO, destination.PRE_DETALLE);
        }