internal void Update(InputInvoice parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            this.OidFactura = parent.Oid;

            ValidationRules.CheckRules();

            if (!IsValid)
            {
                throw new iQValidationException(moleQule.Resources.Messages.GENERIC_VALIDATION_ERROR);
            }

            SessionCode = parent.SessionCode;
            InputInvoiceLineRecord obj = Session().Get <InputInvoiceLineRecord>(Oid);

            long oid_exp_old = obj.OidExpediente;

            obj.CopyValues(_base.Record);
            Session().Update(obj);

            if ((OidExpediente != 0) && (parent.OidExpediente != OidExpediente))
            {
                Store.Expedient.Get(OidExpediente, false, true, parent.SessionCode);
            }

            if ((oid_exp_old != 0) && (OidExpediente != oid_exp_old))
            {
                Store.Expedient.Get(oid_exp_old, false, true, parent.SessionCode);

                InputDeliveryLineInfo ca = InputDeliveryLineInfo.Get(OidConceptoAlbaran, false);

                if (ca.OidExpediente != OidExpediente)
                {
                    InputDelivery albaran = InputDelivery.Get(ca.OidAlbaran, ETipoAcreedor.Todos, true, SessionCode);

                    albaran.Conceptos.GetItem(ca.Oid).OidExpediente = OidExpediente;

                    albaran.SaveAsChild();
                }
            }

            MarkOld();
        }
        public List <CuentaResumen> GetCuentas()
        {
            try
            {
                List <CuentaResumen> list      = new List <CuentaResumen>();
                ProductList          productos = ProductList.GetList(false, true);
                FamiliaList          familias  = FamiliaList.GetList(false, true);
                bool        nuevo;
                ProductInfo producto;
                FamiliaInfo familia;
                string      cuenta;

                foreach (InputInvoiceLineInfo item in _conceptos)
                {
                    nuevo    = true;
                    producto = productos.GetItem(item.OidProducto);
                    if (producto == null)
                    {
                        producto = productos.GetItem(InputDeliveryLineInfo.Get(item.OidConceptoAlbaran, false).OidProducto);
                    }
                    familia = familias.GetItem(producto.OidFamilia);

                    cuenta = (producto.CuentaContableCompra == string.Empty) ? familia.CuentaContableCompra : producto.CuentaContableCompra;

                    //Agrupamos los conceptos por cuentas contables
                    for (int i = 0; i < list.Count; i++)
                    {
                        CuentaResumen cr = list[i];

                        //Tiene prioridad la cuenta contable del producto
                        if (producto.CuentaContableCompra != string.Empty)
                        {
                            if (cr.CuentaContable == producto.CuentaContableCompra)
                            {
                                cr.Importe += item.BaseImponible;
                                list[i]     = cr;
                                nuevo       = false;
                                break;
                            }
                        }
                        //Luego la de la familia
                        else if (cr.CuentaContable == familia.CuentaContableCompra)
                        {
                            cr.Importe += item.BaseImponible;
                            list[i]     = cr;
                            nuevo       = false;
                            break;
                        }
                    }

                    if (nuevo)
                    {
                        list.Add(new CuentaResumen {
                            OidFamilia     = producto.OidFamilia,
                            Importe        = item.BaseImponible,
                            CuentaContable = cuenta
                        });
                    }
                }

                return(list);
            }
            catch
            {
                throw new iQException(String.Format(Resources.Messages.ERROR_FACTURA_CUENTA, NFactura, Acreedor));
            }
        }