Example #1
0
 public static void EditItem(IBankLine source, IBankLineInfo oldSource, int sessionCode)
 {
     EditItem(source, oldSource, 1, sessionCode);
 }
Example #2
0
        public static void EditItem(IBankLine source, IBankLineInfo oldSource, long oid_caja, int sessionCode)
        {
            if (source.EEstado == EEstado.Anulado ||
                (source is Payment && (source as Payment).EEstadoPago != EEstado.Pagado) ||
                (source is Charge && (source as Charge).EEstadoCobro != EEstado.Charged))
            {
                //Anulamos la salida de caja correspondiente
                AnulaItem(source, oid_caja, sessionCode);
                return;
            }

            switch (source.EMedioPago)
            {
            case EMedioPago.Efectivo:
            {
                Cash     caja = Cash.Get(oid_caja, sessionCode);
                CashLine lc   = null;

                switch (source.ETipoMovimientoBanco)
                {
                case EBankLineType.PagoFactura:
                case EBankLineType.PagoGasto:
                case EBankLineType.PagoNomina:
                case EBankLineType.Prestamo:
                case EBankLineType.PagoPrestamo:

                    lc = caja.Lines.GetItemByPayment(source.Oid);
                    break;

                case EBankLineType.Cobro:

                    lc = caja.Lines.GetItemByCharge(source.Oid);
                    break;
                }

                if (lc == null)
                {
                    CashLineInfo info = null;

                    switch (source.ETipoMovimientoBanco)
                    {
                    case EBankLineType.PagoFactura:
                    case EBankLineType.PagoGasto:
                    case EBankLineType.PagoNomina:
                    case EBankLineType.Prestamo:

                        info = CashLineInfo.GetByPago(source.Oid);
                        break;

                    case EBankLineType.Cobro:

                        info = CashLineInfo.GetByCobro(source.Oid);
                        break;
                    }

                    if (info != null && info.OidCierre != 0)
                    {
                        throw new iQInfoException(Resources.Messages.LINEA_INCLUIDA_CIERRE, string.Empty, iQExceptionCode.WARNING);
                    }

                    if ((source is Payment &&
                         (oldSource as PaymentInfo).EEstadoPago == EEstado.Pendiente &&
                         (source as Payment).EEstadoPago == EEstado.Pagado) ||
                        (source is Charge &&
                         (oldSource as ChargeInfo).EEstadoCobro == EEstado.Pendiente &&
                         (source as Charge).EEstadoCobro == EEstado.Charged))
                    {
                        InsertItem(source, sessionCode);
                    }
                    return;
                }

                lc.CopyFrom(source);
                if (source.ETipoMovimientoBanco == EBankLineType.PagoPrestamo)
                {
                    Payment pago = (Payment)source;
                    lc.Haber = pago.Importe + pago.GastosBancarios;
                }
                caja.UpdateSaldo();
                caja.SaveAsChild();
            }
            break;
            }
        }
 /// <summary>
 /// Crea un nuevo elemento y lo aƱade a la lista
 /// </summary>
 /// <returns>Nuevo item</returns>
 public BankLine NewItem(IBankLineInfo parent)
 {
     this.NewItem(BankLine.NewChild(parent));
     return(this[Count - 1]);
 }