Example #1
0
        private void SaveNewDetails()
        {
            if (ConfirmDialog("Desea Guardar los Cambios", "Guardar"))
            {
                // issue resolved Factura consumidor final no tiene cuenta contable.
                if (serie.SeriesName == "ANC")
                {
                    SelectedDownPayment.CardCode = SelectedPartner.CardCode;
                }

                if (SelectedDownPayment.IdDownPayment == 0)
                {
                    DownPaymentHelper.Add(SelectedDownPayment);
                }

                DownPaymentDetail.WhsCode      = SelectedDownPayment.WhsCode;
                DownPaymentDetail.AcctCode     = Config.DownPaymentAcc;
                DownPaymentDetail.TaxCode      = SelectedDownPayment != null && SelectedDownPayment.Series == 31 ? Config.IVACOF : "IVACRF";
                SelectedDownPayment.DocTotal   = (decimal)DownPaymentDetail.Price;
                SelectedDownPayment.PaymentAcc = SelectedDownPayment.PaymentType.AcctCode;
                if (DownPaymentDetail.IdDownPaymentL == 0)
                {
                    SelectedDownPayment.DPI1_DownPaymentDetail.Add(DownPaymentDetail);
                }
                SaveChanges();
            }
            else
            {
                UndoChanges();
            }
            CheckBookHelper.SetNextCheckBookNumber(SelectedDownPayment.Series, SelectedDownPayment.NumAtCard, onErrorAction: ShowErrorMessageBox);
            ForceRefresh = true;
            RaisePropertyChanged("DownPaymentCollection");
            ViewModelManager.CloseModal();
        }
Example #2
0
        private void CheckErrorInBookNumber()
        {
            CheckBookItem = CheckBookHelper.GetCheckBookNumber(serie.Series);

            switch (CheckBookItem.ErrorCode)
            {
            case 0:
                ErrorMessage = string.Empty;
                if (SelectedDownPayment == null)
                {
                    return;
                }
                SelectedDownPayment.NumAtCard = checkBookItem.Number.ToString(CultureInfo.InvariantCulture);
                break;

            case 1:
                if (SelectedDownPayment == null)
                {
                    return;
                }
                ErrorMessage = CheckBookItem.ErrorMessage;
                SelectedDownPayment.NumAtCard = string.Empty;
                break;

            default:
                //todo: hacer el error máximo
                break;
            }
            RaisePropertyChanged("IsReadOnlyCheckBookNumber");
        }
Example #3
0
 public override void ExecuteCancelation()
 {
     CheckBook.StateL = CheckBookStatus.Anulado;
     CheckBookHelper.Update();
     ForceRefresh = true;
     RaisePropertyChanged("CheckBooksCollection");
 }
Example #4
0
 public override void ExecuteActivation()
 {
     CheckBook.StateL = CheckBookStatus.Activo;
     if (CheckBook.NextNumberL == 0)
     {
         CheckBook.NextNumberL = 1;
     }
     CheckBookHelper.Update();
     ForceRefresh = true;
     RaisePropertyChanged("CheckBooksCollection");
 }
Example #5
0
        private void NewProcess()
        {
            DownPaymentHelper.Add(SelectedDownPayment);
            IsBusy = true;
            var confirmed = ConfirmDialog("Desea guardar y procesar los Cambios", "Procesar");

            ShowProcessLoader(this);

            AsyncHelper.DoAsync(() =>
            {
                if (confirmed)
                {
                    if (SelectedDownPayment.IdDownPayment == 0)
                    {
                        // issue resolved Factura consumidor final no tiene cuenta contable.
                        if (serie.SeriesName == "ANC")
                        {
                            SelectedDownPayment.CardCode = SelectedPartner.CardCode;
                        }

                        //SelectedDownPayment.StateL = LocalStatus.Pendiente;
                        DownPaymentDetail.WhsCode  = SelectedDownPayment.WhsCode;
                        DownPaymentDetail.AcctCode = Config.DownPaymentAcc;
                        DownPaymentDetail.TaxCode  = SelectedDownPayment != null && SelectedDownPayment.Series == 31 ? Config.IVACOF : "IVACRF";
                        if (DownPaymentDetail != null && DownPaymentDetail.Price.HasValue)
                        {
                            SelectedDownPayment.DocTotal = (decimal)DownPaymentDetail.Price;
                        }
                        SelectedDownPayment.DPI1_DownPaymentDetail.Add(DownPaymentDetail);

                        SaveChanges();
                        CheckBookHelper.SetNextCheckBookNumber((int)SelectedDownPayment.Series,
                                                               Convert.ToInt32(SelectedDownPayment.NumAtCard));

                        SaveChanges();
                    }
                }
                else
                {
                    UndoChanges();
                }
                Synchronization.Synchronize(SelectedDownPayment);
                IsBusy = false;
                SaveChanges();

                RefreshItemSource();
            }, ViewModelManager.CloseProcessLoader);
        }
Example #6
0
        private void CreateCheckbook()
        {
            if (CheckBook.LastNumL < CheckBook.InitialNumL)
            {
                ErrorMessage = "El rango de valores de la excepción no corresponde al rango de valores del talonario activo";
                return;
            }

            CheckBook.StateL        = 0;
            CheckBook.NextNumberL   = 1;
            CheckBook.DateL         = DateTime.Now;
            CheckBook.CreatedDateL  = DateTime.Now;
            CheckBook.CreatedByL    = Config.CurrentUser;
            CheckBook.ModifiedDateL = DateTime.Now;
            CheckBook.ModifiedByL   = Config.CurrentUser;

            CheckBookHelper.Add(CheckBook);

            ViewModelManager.CloseModal();
            CheckBooksCollection.Add(CheckBook);
        }
Example #7
0
        private void NewProcess()
        {
            CurrentOperation = Operations.Process;
            var autorizacion = SalesDetailsCollection.ToList().Any(dc => dc.PriceEdited);

            if (!UserIsValid && autorizacion)
            {
                ShowUserValidatorPicker();
                return;
            }

            IsBusy = IsDetailsBusy = true;
            if (SalesHelper.VerifyNumAtCard(SelectedSale))
            {
                if (!ShowWarningMessage("Numero de Factura Repetido, Desea continuar de todas formas ?"))
                {
                    IsBusy = IsDetailsBusy = false;
                    return;
                }
            }

            if (!ConfirmDialog("Desea procesar la venta?", "procesar"))
            {
                UndoChanges();
                IsBusy = IsDetailsBusy = false;
                return;
            }
            ViewModelManager.CloseModal();
            ShowProcessLoader(this);
            AsyncHelper.DoAsync(() =>
            {
                if (!Exento && !WithHolding)
                {
                    CheckIVACOM(true);
                }
                else
                {
                    CheckIVAEXE(Exento);
                    CheckIVARET(WithHolding);
                }

                //SelectedSale.StateL = LocalStatus.Pendiente;
                SalesHelper.AddSale(SelectedSale);
                if (HasDownPayment && SelectedDownPayment != null)
                {
                    SelectedDownPayment         = SelectedDownPayment.ForceUpdateToDataBase();
                    SelectedDownPayment.IdSaleL = SelectedSale.IdSaleL;
                }
                else if (SelectedDownPayment != null)
                {
                    SelectedDownPayment.IdSaleL = null;
                }

                SaveChanges();

                CheckBookHelper.SetNextCheckBookNumber((int)SelectedSale.Series,
                                                       Convert.ToInt32(selectedSale.NumAtCard));


                Synchronization.Synchronize(SelectedSale);


                IsBusy = IsDetailsBusy = false;

                SaveChanges();
                RefreshItemSource();
            }, ViewModelManager.CloseProcessLoader);
        }
Example #8
0
        private void SaveNewDetails()
        {
            CurrentOperation = Operations.Save;
            var autorizacion = SalesDetailsCollection.ToList().Any(dc => dc.PriceEdited);

            if (!UserIsValid && autorizacion)
            {
                ShowUserValidatorPicker();
                return;
            }

            if (SalesHelper.VerifyNumAtCard(SelectedSale))
            {
                if (ShowWarningMessage("Numero de Factura Repetido, Desea continuar de todas formas ?"))
                {
                    return;
                }
                IsBusy = IsDetailsBusy = false;
                return;
            }


            if (!ConfirmDialog("Desea Guardar Los Cambios", "Guardar"))
            {
                UndoChanges();
                return;
            }

            // Excluir articulos no inventariables.
            var productsToExclude = ArticlesHelper.GetProductsOnInventory(SalesDetailsCollection.Select(d => d.ItemCode).ToList());

            //.Where(p=> p.OITM_Articles.InvntItem.Contains("Y"))
            var isnotValid = SalesDetailsCollection.Where(p => !productsToExclude.Contains(p.ItemCode))

                             .Any(d =>
            {
                if (d.Quantity > d.OnHand)
                {
                    ErrorMessage = string.Format("El Articulo : {0} Codigo {1} ,Quedara en Negativo", d.Dscription, d.ItemCode);
                    ShowErrorMessageBox(ErrorMessage);
                    return(true);
                }

                ErrorMessage = string.Empty;
                return(false);
            });

            if (isnotValid)
            {
                return;
            }

            if (!Exento && !WithHolding)
            {
                CheckIVACOM(true);
            }
            else
            {
                CheckIVAEXE(Exento);
                CheckIVARET(WithHolding);
            }
            if (!HasDownPayment)
            {
                SelectedSale.dpEntry = 0;
            }
            SalesHelper.AddSale(SelectedSale);
            //if (SelectedDownPayment != null)
            //{
            //    if (HasDownPayment) SelectedDownPayment.IdSaleL = SelectedSale.IdSaleL; else SelectedDownPayment.IdSaleL = null;
            //}


            SaveChanges();

            // TODO validar los valores Series y NumAtCard  son diferentes de null ,
            //y considerar el caso en que los valores son 0

            if (SelectedSale == null)
            {
                return;                       // TODO Show error Message
            }
            var serieNumber = (int)(SelectedSale.Series.HasValue? SelectedSale.Series : 0);
            var numAtcoard  = !string.IsNullOrEmpty(SelectedSale.NumAtCard)
                            ? Convert.ToInt32(SelectedSale.NumAtCard)
                            : 0;

            CheckBookHelper.SetNextCheckBookNumber(serieNumber, numAtcoard);
            ViewModelManager.CloseModal();
            RefreshItemSource();
        }