Пример #1
0
        protected virtual bool Asignar()
        {
            if (_entity.Pendiente == 0)
            {
                PgMng.ShowInfoException("No existe cantidad pendiente de asignación en este cobro.");
                return(false);
            }

            if (NoAsignado > _entity.Pendiente)
            {
                PgMng.ShowInfoException(string.Format("La asignación {0:C2} es superior a la cantidad pendiente en el cobro {1:C2}.", NoAsignado, _entity.Pendiente));
                return(false);
            }

            foreach (FacREAInfo item in _facturas)
            {
                REAExpedient rea_expedient = _rea_expedients.GetItem(item.OidExpedienteREA);

                if (item.Vinculado == Library.Invoice.Resources.Labels.RESET_COBRO)
                {
                    try
                    {
                        if (item.Asignado < 0)
                        {
                            PgMng.ShowInfoException(string.Format("El importe de la asignación del expediente {0} es negativo.", item.NExpediente));
                            return(false);
                        }

                        CobroREA c = _entity.CobroREAs.GetItemByExpedienteREA(item.OidExpedienteREA);
                        if ((item.Asignado > item.TotalAyuda) && (c == null))
                        {
                            PgMng.ShowInfoException(string.Format("El importe de la asignación del expediente {0} es superior a la cantidad pendiente de cobro.", item.NExpediente));
                            return(false);
                        }
                    }
                    catch
                    {
                        PgMng.ShowInfoException(string.Format("El valor asignado al expediente {0} no es válido.", item.NExpediente));
                        return(false);
                    }

                    if (rea_expedient != null)
                    {
                        rea_expedient.EEstado = EEstado.Charged;
                    }
                }
                else
                {
                    if (rea_expedient != null)
                    {
                        if (rea_expedient.EEstado == EEstado.Charged)
                        {
                            rea_expedient.EEstado = EEstado.Abierto;
                        }
                    }
                }
            }

            return(true);
        }
Пример #2
0
        protected virtual bool Asignar()
        {
            if (_entity.Pendiente == 0)
            {
                PgMng.ShowInfoException("No existe cantidad pendiente de asignación en este cobro.");
                return(false);
            }

            if (NoAsignado > _entity.Pendiente)
            {
                PgMng.ShowInfoException(string.Format("La asignación {0:C2} es superior a la cantidad pendiente en el cobro {1:C2}.", NoAsignado, _entity.Pendiente));
                return(false);
            }

            foreach (LineaFomentoInfo item in _facturas)
            {
                if (item.Vinculado == Library.Invoice.Resources.Labels.SET_COBRO)
                {
                    try
                    {
                        if (item.Asignado < 0)
                        {
                            PgMng.ShowInfoException(string.Format("El importe de la asignación del expediente {0} es negativo.", item.IDExpediente));
                            return(false);
                        }

                        CobroREA c = _entity.CobroREAs.GetItemByExpedienteREA(item.Oid);
                        if ((item.Asignado > item.Total) && (c == null))
                        {
                            PgMng.ShowInfoException(string.Format("El importe de la asignación del expediente {0} es superior a la cantidad pendiente de cobro.", item.IDExpediente));
                            return(false);
                        }
                    }
                    catch
                    {
                        PgMng.ShowInfoException(string.Format("El valor asignado al expediente {0} no es válido.", item.IDExpediente));
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #3
0
        protected override void DesvinculaFacturaAction(DataGridViewRow row)
        {
            if (row == null)
            {
                return;
            }

            FacREAInfo item = row.DataBoundItem as FacREAInfo;

            item.Asignado = 0;

            CobroREA cobro = Entity.CobroREAs.GetItemByExpedienteREA(item.OidExpedienteREA);

            if (cobro != null)
            {
                _entity.CobroREAs.Remove(cobro);
            }

            UpdateAsignado();

            MarkAsActiva(row);
        }
Пример #4
0
        protected void ApportionAction(DataGridViewRow row, decimal totalSolicitado)
        {
            if (row == null)
            {
                return;
            }

            LineaFomentoInfo item = row.DataBoundItem as LineaFomentoInfo;

            if (item == null)
            {
                return;
            }

            item.Cobrado = true;

            decimal proportion = (_entity.Importe != 0)
                                                                                ? _entity.Importe * (item.Pendiente * 100 / totalSolicitado) / 100
                                                                                : 0;

            //Cobros en positivo
            if (_entity.Importe >= 0)
            {
                if (proportion <= NoAsignado)
                {
                    item.Asignado = proportion;
                }
                else
                {
                    item.Asignado = NoAsignado;
                }
            }
            //Cobros en negativo. Abonos
            else
            {
                if (proportion >= NoAsignado)
                {
                    item.Asignado = proportion;
                }
                else
                {
                    item.Asignado = NoAsignado;
                }
            }

            CobroREA cobro = _entity.CobroREAs.GetItemByExpedienteREA(item.Oid);

            if (cobro == null)
            {
                cobro = _entity.CobroREAs.NewItem(_entity, item);
                item.FechaAsignacion = DateTime.Now.ToShortDateString();
            }
            else
            {
                cobro.CopyFrom(_entity, item);
                item.FechaAsignacion = DateTime.Now.ToShortDateString();
            }

            UpdateAsignado();

            MarkAsNoActiva(row);
        }
Пример #5
0
        protected void VinculaFacturaAction(DataGridViewRow row, bool inputValue)
        {
            if (row == null)
            {
                return;
            }

            //if (NoAsignado == 0)
            //{
            //    DesvinculaFacturaAction(row);
            //    return;
            //}

            LineaFomentoInfo item = row.DataBoundItem as LineaFomentoInfo;

            if (item == null)
            {
                return;
            }

            item.Cobrado = true;

            //Se le ha asignado algo a mano
            if (item.Asignado != 0 || inputValue)
            {
                //Cobros en positivo
                if (_entity.Importe >= 0)
                {
                    if (item.Asignado > NoAsignado)
                    {
                        item.Asignado = NoAsignado;
                    }
                    //if (item.Asignado > item.Pendiente) item.Asignado = item.Pendiente;
                }
                //Cobros en negativo. Abonos
                else
                {
                    if (item.Asignado < NoAsignado)
                    {
                        item.Asignado = NoAsignado;
                    }
                    if (item.Asignado < item.Pendiente)
                    {
                        item.Asignado = item.Pendiente;
                    }
                }
            }
            else
            {
                //Cobros en positivo
                if (_entity.Importe >= 0)
                {
                    if (item.Pendiente <= NoAsignado)
                    {
                        item.Asignado = item.Pendiente;
                    }
                    else
                    {
                        item.Asignado = NoAsignado;
                    }
                }
                //Cobros en negativo. Abonos
                else
                {
                    if (item.Pendiente >= NoAsignado)
                    {
                        item.Asignado = item.Pendiente;
                    }
                    else
                    {
                        item.Asignado = NoAsignado;
                    }
                }
            }

            CobroREA cobro = _entity.CobroREAs.GetItemByExpedienteREA(item.Oid);

            if (cobro == null)
            {
                cobro = _entity.CobroREAs.NewItem(_entity, item);
                item.FechaAsignacion = DateTime.Now.ToShortDateString();
            }
            else
            {
                cobro.CopyFrom(_entity, item);
                item.FechaAsignacion = DateTime.Now.ToShortDateString();
            }

            UpdateAsignado();

            MarkAsNoActiva(row);
        }
Пример #6
0
        protected override void LinkREAExpedientAction(DataGridViewRow row)
        {
            if (row == null)
            {
                return;
            }

            if (NoAsignado == 0)
            {
                UnlinkREAExpedientAction(row);
                return;
            }

            FacREAInfo item = row.DataBoundItem as FacREAInfo;

            if (item == null)
            {
                return;
            }

            //Se le ha asignado algo a mano
            if (item.Asignado != 0)
            {
                //Cobros en positivo
                if (_entity.Importe >= 0)
                {
                    if (item.Asignado > NoAsignado)
                    {
                        item.Asignado = NoAsignado;
                    }
                    //if (item.Asignado > item.Pendiente) item.Asignado = item.Pendiente;
                }
                //Cobros en negativo. Abonos
                else
                {
                    if (item.Asignado < NoAsignado)
                    {
                        item.Asignado = NoAsignado;
                    }
                    if (item.Asignado < item.Pendiente)
                    {
                        item.Asignado = item.Pendiente;
                    }
                }
            }
            else
            {
                //Cobros en positivo
                if (_entity.Importe >= 0)
                {
                    if (item.Pendiente <= NoAsignado)
                    {
                        item.Asignado = item.Pendiente;
                    }
                    else
                    {
                        item.Asignado = NoAsignado;
                    }
                }
                //Cobros en negativo. Abonos
                else
                {
                    if (item.Pendiente >= NoAsignado)
                    {
                        item.Asignado = item.Pendiente;
                    }
                    else
                    {
                        item.Asignado = NoAsignado;
                    }
                }
            }

            CobroREA cobro = _entity.CobroREAs.GetItemByExpedienteREA(item.OidExpedienteREA);

            if (cobro == null)
            {
                cobro = _entity.CobroREAs.NewItem(_entity, item);
                item.FechaAsignacion = DateTime.Now.ToShortDateString();
            }
            else
            {
                cobro.CopyFrom(_entity, item);
                item.FechaAsignacion = DateTime.Now.ToShortDateString();
            }

            UpdateAsignado();

            MarkAsNoActiva(row);
        }