コード例 #1
0
        public static void AnulaItem(IBankLine source, long oid_caja, int sessionCode)
        {
            switch (source.EMedioPago)
            {
            //Anulamos la salida de caja correspondiente
            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:

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

                case EBankLineType.Cobro:

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

                if (lc != null)
                {
                    lc.EEstado = EEstado.Anulado;
                    caja.UpdateSaldo();
                    caja.SaveAsChild();
                    //caja.CloseSession();
                }
                else
                {
                    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);
                    }
                }
            }
            break;
            }
        }
コード例 #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;
            }
        }