示例#1
0
        public Factura(
            int id,
            int idCdad,
            int?idProv,
            string nFactura,
            DateTime?fecha,
            bool autoCalc,
            decimal subtotal,
            double puIi,
            double puIrpf,
            decimal ii,
            decimal irpf,
            decimal pendiente,
            string concepto,
            TipoPagoFacturas tipoPago      = TipoPagoFacturas.Cheque,
            GastosPagosList <Gasto> gastos = null,
            GastosPagosList <Pago> pagos   = null)
        {
            decimal II   = subtotal.MultiplyDouble(puIi);
            decimal Irpf = subtotal.MultiplyDouble(puIrpf);

            if (ii != II || irpf != Irpf)
            {
                throw new CustomException_ObjModels("Error al intentar crear objeto Factura en constructor. Factura no cuadrada");
            }

            decimal total = subtotal + ii - irpf;

            if ((gastos != null && gastos.Total != subtotal) ||
                (pagos != null && (total - pagos.Total) != pendiente))
            {
                throw new CustomException_ObjModels("Error al intentar crear objeto Factura en constructor. Factura no cuadrada");
            }

            this._Id = id;
            this._IdOwnerComunidad = idCdad;
            this._IdOwnerProveedor = idProv;
            this._NFactura         = nFactura;
            this.Fecha             = (DateTime)(fecha ?? DateTime.Today);
            this.AutoCalc          = autoCalc;
            this._Subtotal         = subtotal;
            this._PerUnitIGICIVA   = puIi;
            this._IGICIVA          = ii;
            this._PerUnitIRPF      = puIrpf;
            this._IRPF             = irpf;
            this._Pendiente        = pendiente;
            this.Concepto          = concepto;
            this.TipoPago          = tipoPago;
            this._GastosFra        = gastos;
            this._PagosFra         = pagos;
        }
示例#2
0
        public bool TrySetGastosPagos(GastosPagosList <Gasto> gastos, GastosPagosList <Pago> pagos)
        {
            decimal pendiente = gastos.Total - pagos.Total;

            if (this._Pendiente == pendiente || (gastos.Total + this.TotalImpuestos) != this.Total)
            {
                return(false);
            }

            this._GastosFra = gastos;
            this._PagosFra  = pagos;
            this._Pendiente = pendiente;

            return(true);
        }
示例#3
0
        /*#region helpers
         * public bool FacturaLiteralCuadrada(decimal subtotal, double perUnitII, double perUnitIRPF)
         * {
         *  decimal II = subtotal.MultiplyDouble(perUnitII);
         *  decimal Irpf = subtotal.MultiplyDouble(perUnitIRPF);
         *
         *  return (subtotal + II - Irpf) == this.Total;
         * }
         * public bool FacturaLiteralCuadrada(decimal subtotal, decimal igiciva, decimal irpf)
         * {
         *  return (subtotal + igiciva - irpf) == this.Total;
         * }
         * public bool GastosCuadranFactura(decimal gastos, decimal subtotal, double perUnitII, double perUnitIRPF)
         * {
         *  decimal II = subtotal.MultiplyDouble(perUnitII);
         *  decimal Irpf = subtotal.MultiplyDouble(perUnitIRPF);
         *
         *  return (subtotal + II - Irpf) == this.Total;
         * }
         *
         * private void ReCalculate()
         * {
         *  this._IGICIVA = this.Subtotal.MultiplyDouble(this.PerUnitIGICIVA);
         *  this._IRPF = this.Subtotal.MultiplyDouble(this.PerUnitIRPF);
         *  this._Total = this.Subtotal + this.IGICIVA - this.IRPF;
         *  this._Pendiente = this.Total - this.PagosFra.Total;
         * }
         #endregion*/

        #region public methods
        public ErrorCuadreFactura FacturaCuadrada(
            decimal subtotal,
            double perUnitIGICIVA,
            decimal igiciva,
            double perUnitIRPF,
            decimal irpf,
            decimal total,
            decimal pendiente,
            GastosPagosList <Gasto> gastos,
            GastosPagosList <Pago> pagos)
        {
            decimal II   = subtotal.MultiplyDouble(perUnitIGICIVA);
            decimal Irpf = subtotal.MultiplyDouble(perUnitIRPF);

            if (igiciva != II)
            {
                return(ErrorCuadreFactura.ErrorEnCalculoIGICIVA);
            }
            else if (irpf != Irpf)
            {
                return(ErrorCuadreFactura.ErrorEnCalculoIRPF);
            }

            decimal Total = subtotal + igiciva - irpf;

            if (total != Total)
            {
                return(ErrorCuadreFactura.ErrorEnTotal);
            }
            else if (gastos != null && gastos.Total != subtotal)
            {
                return(ErrorCuadreFactura.GastosNoCoincidenConSubtotal);
            }
            else if (pagos != null && (total - pagos.Total) != pendiente)
            {
                return(ErrorCuadreFactura.PendienteDescuadrado);
            }

            return(ErrorCuadreFactura.None);
        }