Example #1
0
        public override void OpenAddForm()
        {
            InputInvoiceAddForm form = new InputInvoiceAddForm(this);

            AddForm(form);
            _entity = (form.ActionResult == DialogResult.OK) ? form.Entity : null;
        }
        private void CopyFactura()
        {
            Factura = InputInvoice.New(_entity).GetInfo(true);

            List <InputInvoiceLineInfo> conceptosOut = new List <InputInvoiceLineInfo>();

            foreach (InputInvoiceLineInfo item in Factura.Conceptos)
            {
                bool isIn = false;

                foreach (InputInvoiceLineInfo cp in _conceptos_selected)
                {
                    if (cp.Oid == item.Oid)
                    {
                        isIn = true;
                        continue;
                    }
                }

                if (!isIn)
                {
                    conceptosOut.Add(item);
                }
            }

            foreach (InputInvoiceLineInfo item in conceptosOut)
            {
                Factura.Conceptos.RemoveItem(item.Oid);
            }

            Factura.CalculateTotal();
        }
Example #3
0
        public Expense NewItem(Expedient parent, InputInvoice fac)
        {
            Expense item = Expense.NewChild(parent, fac);

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

            OidFactura = parent.Oid;

            ValidationRules.CheckRules();

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

            parent.Session().Save(_base.Record);

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

            MarkOld();
        }
Example #5
0
 public static void NavigateToInvoice(this INavigationService service, InputInvoice inputInvoice)
 {
     if (service is TLNavigationService serviceEx)
     {
         serviceEx.NavigateToInvoice(inputInvoice);
     }
 }
        internal void Update(InputInvoice parent)
        {
            try
            {
                this.RaiseListChangedEvents = false;

                SessionCode = parent.SessionCode;

                // update (thus deleting) any deleted child objects
                foreach (InputInvoiceLine obj in DeletedList)
                {
                    obj.DeleteSelf(parent);
                }

                // now that they are deleted, remove them from memory too
                DeletedList.Clear();

                // add/update any current child objects
                foreach (InputInvoiceLine obj in this)
                {
                    if (obj.IsNew)
                    {
                        obj.Insert(parent);
                    }
                    else
                    {
                        obj.Update(parent);
                    }
                }
            }
            finally
            {
                this.RaiseListChangedEvents = true;
            }
        }
Example #7
0
        public static InputInvoiceViewModel ConvertToInputInvoiceViewModelLite(this InputInvoice inputInvoice)
        {
            InputInvoiceViewModel inputInvoiceViewModel = new InputInvoiceViewModel()
            {
                Id         = inputInvoice.Id,
                Identifier = inputInvoice.Identifier,

                Code          = inputInvoice.Code,
                Supplier      = inputInvoice.Supplier,
                Address       = inputInvoice.Address,
                InvoiceNumber = inputInvoice.InvoiceNumber,
                InvoiceDate   = inputInvoice.InvoiceDate,
                AmountNet     = inputInvoice.AmountNet,
                PDVPercent    = inputInvoice.PDVPercent,
                PDV           = inputInvoice.PDV,
                AmountGross   = inputInvoice.AmountGross,
                Currency      = inputInvoice.Currency,
                DateOfPaymet  = inputInvoice.DateOfPaymet,
                Status        = inputInvoice.Status,

                StatusDate  = inputInvoice.StatusDate,
                Description = inputInvoice.Description,

                Path = inputInvoice.Path,

                IsActive = inputInvoice.Active,

                UpdatedAt = inputInvoice.UpdatedAt,
                CreatedAt = inputInvoice.CreatedAt
            };


            return(inputInvoiceViewModel);
        }
Example #8
0
        public Expense NewItem(Expedient parent, InputInvoice fac, ECategoriaGasto tipo)
        {
            Expense item = Expense.NewChild(parent, fac, tipo);

            this.AddItem(item);
            return(item);
        }
Example #9
0
        public static CQueryDef SaveIntoProviderOffersProducts(InputInvoice Invoice, InputProduct Product)
        {
            var sql = string.Format(@"INSERT INTO [ProviderOffers_Products](Product_Key, Count, Price, Purchase_Key) VALUES('{0}', '{1}', '{2}', '{3}')",
                                    Product.Product_Key, Product.Count, Product.Price, Invoice._purchaseKey);

            return(new CQueryDef(sql, CSqlReader.SqlStorage.ExecuteNonQuery));
        }
Example #10
0
        internal void DeleteSelf(InputInvoice parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }

            try
            {
                SessionCode = parent.SessionCode;
                Session().Delete(Session().Get <InputDeliveryInvoiceRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
        protected override void GetFormSourceData(long oid, object[] parameters)
        {
            ETipoAcreedor tipo = (ETipoAcreedor)parameters[0];

            _entity = InputInvoice.Get(oid, tipo);
            _entity.BeginEdit();
        }
Example #12
0
 public void SaveInputInvoice(InputInvoice invoice, List <InputProduct> products)
 {
     doQuery.Start(SqlQueries.SaveIntoProviderOffers(invoice));
     foreach (var p in products)
     {
         doQuery.Start(SqlQueries.SaveIntoProviderOffersProducts(invoice, p));
     }
 }
Example #13
0
 public static NavigationState GetInvoice(InputInvoice invoice)
 {
     return(invoice switch
     {
         InputInvoiceMessage message => GetInvoice(message.ChatId, message.MessageId),
         InputInvoiceName name => GetInvoice(name.Name),
         _ => null
     });
Example #14
0
        private void BUT_Save_Click(object sender, EventArgs e)
        {
            _invoice = new InputInvoice(Convert.ToInt32(TB_InvoiceNumber.Text), _products[0].Date, _products[0].ProviderId);
            _queries.SaveInputInvoice(_invoice, _products);
            _queries.SaveProductsBoughtCount(_products);

            this.Close();
        }
        public static InputInvoiceLines GetChildList(InputInvoice parent, bool childs)
        {
            CriteriaEx criteria = InputInvoiceLine.GetCriteria(parent.SessionCode);

            criteria.Query  = SELECT(parent);
            criteria.Childs = childs;

            return(DataPortal.Fetch <InputInvoiceLines>(criteria));
        }
        public static AlbaranFacturasProveedores GetChildList(InputInvoice parent, bool childs)
        {
            CriteriaEx criteria = AlbaranFacturaProveedor.GetCriteria(parent.SessionCode);

            criteria.Query  = AlbaranFacturasProveedores.SELECT_BY_FACTURA(parent.Oid);
            criteria.Childs = childs;

            return(DataPortal.Fetch <AlbaranFacturasProveedores>(criteria));
        }
        protected void CopyValues(InputInvoice source)
        {
            if (source == null)
            {
                return;
            }

            Oid = source.Oid;
            _base.CopyValues(source);
        }
Example #18
0
    //Deletar
    public void Remove(int id)
    {
        InputInvoice i = new InputInvoice()
        {
            _idII = id
        };

        contexto.InputInvoice.Remove(i);
        contexto.SaveChanges();
    }
Example #19
0
        public static List <InputInvoiceViewModel> ConvertToInputInvoiceViewModelList(this IEnumerable <InputInvoice> InputInvoices)
        {
            List <InputInvoiceViewModel> viewModels = new List <InputInvoiceViewModel>();

            foreach (InputInvoice InputInvoice in InputInvoices)
            {
                viewModels.Add(InputInvoice.ConvertToInputInvoiceViewModel());
            }
            return(viewModels);
        }
Example #20
0
        public PaymentAddressPopup(InputInvoice inputInvoice, Invoice invoice, OrderInfo info)
        {
            InitializeComponent();
            DataContext = TLContainer.Current.Resolve <PaymentAddressViewModel>();

            Title               = Strings.Resources.PaymentShippingInfo;
            PrimaryButtonText   = Strings.Resources.OK;
            SecondaryButtonText = Strings.Resources.Cancel;

            ViewModel.Initialize(inputInvoice, invoice, info);
        }
        public static string SELECT(InputInvoice factura)
        {
            string query;

            QueryConditions conditions = new QueryConditions {
                FacturaRecibida = factura.GetInfo(false)
            };

            query = InputInvoiceLine.SELECT(conditions, true);

            return(query);
        }
Example #22
0
        public void Initialize(InputInvoice inputInvoice, Invoice invoice, OrderInfo info)
        {
            _inputInvoice = inputInvoice;

            info ??= new OrderInfo();
            info.ShippingAddress ??= new Address();

            Invoice = invoice;
            Info    = info;

            SelectedCountry = Country.All.FirstOrDefault(x => x.Code.Equals(info.ShippingAddress.CountryCode, StringComparison.OrdinalIgnoreCase));
        }
        public void Remove(InputInvoice factura, InputDeliveryInfo AlbaranProveedor)
        {
            foreach (AlbaranFacturaProveedor item in this)
            {
                if (item.OidFactura == factura.Oid && item.OidAlbaran == AlbaranProveedor.Oid)
                {
                    this.Remove(item);
                    break;
                }
            }

            factura.SetAlbaranes();
        }
        public static InputInvoiceLine NewChild(InputInvoice parent)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(moleQule.Resources.Messages.USER_NOT_ALLOWED);
            }

            InputInvoiceLine obj = new InputInvoiceLine();

            obj.OidFactura = parent.Oid;

            return(obj);
        }
        public InputInvoice Create(InputInvoice inputInvoice)
        {
            if (context.InputInvoices.Where(x => x.Identifier != null && x.Identifier == inputInvoice.Identifier).Count() == 0)
            {
                inputInvoice.Id = 0;

                inputInvoice.Code   = GetNewCodeValue(inputInvoice.CompanyId ?? 0);
                inputInvoice.Active = true;

                inputInvoice.UpdatedAt = DateTime.Now;
                inputInvoice.CreatedAt = DateTime.Now;

                context.InputInvoices.Add(inputInvoice);
                return(inputInvoice);
            }
            else
            {
                // Load favor that will be updated
                InputInvoice dbEntry = context.InputInvoices
                                       .FirstOrDefault(x => x.Identifier == inputInvoice.Identifier && x.Active == true);

                if (dbEntry != null)
                {
                    dbEntry.BusinessPartnerId = inputInvoice.BusinessPartnerId ?? null;
                    dbEntry.CompanyId         = inputInvoice.CompanyId ?? null;
                    dbEntry.CreatedById       = inputInvoice.CreatedById ?? null;

                    // Set properties
                    dbEntry.Code          = inputInvoice.Code;
                    dbEntry.Supplier      = inputInvoice.Supplier;
                    dbEntry.Address       = inputInvoice.Address;
                    dbEntry.InvoiceNumber = inputInvoice.InvoiceNumber;
                    dbEntry.InvoiceDate   = inputInvoice.InvoiceDate;
                    dbEntry.AmountNet     = inputInvoice.AmountNet;
                    dbEntry.PDVPercent    = inputInvoice.PDVPercent;
                    dbEntry.PDV           = inputInvoice.PDV;
                    dbEntry.AmountGross   = inputInvoice.AmountGross;
                    dbEntry.Currency      = inputInvoice.Currency;
                    dbEntry.DateOfPaymet  = inputInvoice.DateOfPaymet;
                    dbEntry.Status        = inputInvoice.Status;
                    dbEntry.StatusDate    = inputInvoice.StatusDate;
                    dbEntry.Description   = inputInvoice.Description;
                    dbEntry.Path          = inputInvoice.Path;

                    // Set timestamp
                    dbEntry.UpdatedAt = DateTime.Now;
                }

                return(dbEntry);
            }
        }
Example #26
0
        public override void UpdateList()
        {
            switch (_current_action)
            {
            case molAction.Add:
                if (_entity == null)
                {
                    return;
                }
                List.AddItem(_entity.GetInfo(false));
                if (FilterType == IFilterType.Filter)
                {
                    InputInvoiceList listA = InputInvoiceList.GetList(_filter_results);
                    listA.AddItem(_entity.GetInfo(false));
                    _filter_results = listA.GetSortedList();
                }
                break;

            case molAction.Edit:
            case molAction.ChangeStateContabilizado:
            case molAction.ChangeStateEmitido:
            case molAction.Unlock:
                if (_entity == null)
                {
                    return;
                }
                ActiveItem.CopyFrom(_entity);
                break;

            case molAction.Delete:
                if (ActiveItem == null)
                {
                    return;
                }
                List.RemoveItem(ActiveItem.Oid);
                if (FilterType == IFilterType.Filter)
                {
                    InputInvoiceList listD = InputInvoiceList.GetList(_filter_results);
                    listD.RemoveItem(ActiveItem.Oid);
                    _filter_results = listD.GetSortedList();
                }
                break;
            }

            RefreshSources();
            if (_entity != null)
            {
                Select(_entity.Oid);
            }
            _entity = null;
        }
 private void CmdDeleteExcute()
 {
     if (invoice != null)
     {
         MessageBoxResult result = MessageBox.Show($"确定要删除当前发票号为{invoice.InvoiceNumber}待输入发票记录?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
         if (result == MessageBoxResult.Yes)
         {
             Invoices.Remove(invoice);
             InputCount = Invoices.Count;
             invoice    = null;
             BtnEnableJudgement();
         }
     }
 }
Example #28
0
        public static InputInvoiceLineList GetByFacturaList(long oid_factura, bool childs)
        {
            InputInvoiceLineList list;

            QueryConditions conditions = new QueryConditions
            {
                FacturaRecibida = InputInvoice.New().GetInfo(false)
            };

            conditions.FacturaRecibida.Oid = oid_factura;

            list = GetList(InputInvoiceLine.SELECT(conditions, false), childs);

            return(list);
        }
Example #29
0
        protected override void GetFormSourceData(object[] parameters)
        {
            _entity = InputInvoice.New();
            _entity.BeginEdit();

            try
            {
                //NO SE PUEDE HACER AQUI LO QUE SE HACE EN EL CONSTRUCTOR PORQUE LOS CONTROLES NO ESTAN INICIALIZADOS
                if (parameters[0] != null)
                {
                    _entity.Fecha = ((InputDeliveryInfo)parameters[0]).Fecha;
                }
            }
            catch { }
        }
        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();
        }