private void SaveCreditNote()
        {
            CreditNote.DocTotal = Total;
            // CreditNote.SeriesTitle = SelectedSerie.SeriesName + " " + SelectedSerie.Remark;
            CreditNote.RIN1_ClientCreditNoteDetail = CreditNoteDetailsCollection.ToList();

            if (CreditNote.IdClientCreditNoteL > 0)
            {
                CreditNote.ModifiedDateL = DateTime.Now;
                CreditNote.ModifiedByL   = Config.CurrentUser;
                CreditNote.StateL        = LocalStatus.Guardado;
                ClientCreditNoteHelper.Update();
                RaisePropertyChanged("CreditNotesCollection");
            }
            else
            {
                FillData();
                CreditNote.StateL = LocalStatus.Guardado;
                ClientCreditNoteHelper.Add(CreditNote);
                // CreditNotesCollection.Add(CreditNote);
            }

            ViewModelManager.CloseModal();

            if (CreditNote.IdClientCreditNoteL == 0)
            {
                MessageBox.Show(
                    "La Nota de Crédito fue creada exitosamente, por favor seleccione la pestaña NOTAS DE CRÉDITO para ver el detalle");
            }
        }
        private void ProcessCreditNote()
        {
//            CreditNote.DocTotal = Total;
            //CreditNote.SeriesTitle = SelectedSerie.SeriesName + " " + SelectedSerie.Remark;
            CreditNote.RIN1_ClientCreditNoteDetail = CreditNoteDetailsCollection.ToList();

            if (CreditNote.IdClientCreditNoteL > 0)
            {
                CreditNote.ModifiedDateL = DateTime.Now;
                CreditNote.ModifiedByL   = Config.CurrentUser;
                //CreditNote.StateL = LocalStatus.Pendiente;
                //ClientCreditNoteHelper.Update();
                SaveChanges();
                //RaisePropertyChanged("CreditNotesCollection");
            }
            else
            {
                FillData();
                //CreditNote.StateL = LocalStatus.Pendiente;
                ClientCreditNoteHelper.Add(CreditNote);
                // CreditNotesCollection.Add(CreditNote);
            }
            Synchronization.Synchronize(CreditNote);


            if (CreditNote.IdClientCreditNoteL == 0)
            {
                MessageBox.Show(
                    "La Nota de Crédito esta en proceso, por favor seleccione la pestaña NOTAS DE CRÉDITO para ver el detalle");
            }

            IsBusy       = false;
            ForceRefresh = true;
            RaisePropertyChanged("CreditNotesCollection");
        }
 private void Deleting()
 {
     if (!ConfirmDelete())
     {
         return;
     }
     ClientCreditNoteHelper.Delete(CreditNote);
     CreditNotesCollection.Remove(CreditNote);
 }
Beispiel #4
0
        private static ORIN_ClientCreditNotes SyncUpload(ORIN_ClientCreditNotes note)
        {
            var result = WebApiClient.AddSaleCreditNote(note).Result;

            note.UpdateModelPropertiesFrom(result.Model);
            note.StateL = LocalStatus.Procesado;
            result.UpdateEntityVersion();
            ClientCreditNoteHelper.SaveTransaction(note);
            return(note);
        }
Beispiel #5
0
        private static void GetClientCreditNotes(LOG_CHANGES changeset)
        {
            var note = WebApiClient.GetSaleCreditNote(changeset.ListVal).Result;

            var db = ContextFactory.GetDBContext();

            var id = Convert.ToInt32(changeset.ListVal);

            var localId = db.ORIN_ClientCreditNotes.Include(c => c.RIN1_ClientCreditNoteDetail)
                          .FirstOrDefault(c => c.IdClientCreditNoteL == changeset.IdL.Value);

            var localDE = db.ORIN_ClientCreditNotes.Include(c => c.RIN1_ClientCreditNoteDetail)
                          .FirstOrDefault(c => c.DocEntry == id);

            if (changeset.IdL.HasValue) // C1
            {
                if (localId == null)    // C3
                {
                    db.ORIN_ClientCreditNotes.Add(note);
                    ContextFactory.SaveChanges();
                    ClientCreditNoteHelper.SaveTransaction(note);
                }
                else
                {
                    if (localId.StateL == LocalStatus.Procesado)                     // C4
                    {
                        if (localDE == null || localDE.DocEntry != localId.DocEntry) // C5
                        {
                            db.ORIN_ClientCreditNotes.Add(note);
                            ClientCreditNoteHelper.SaveTransaction(note);
                        }
                        else
                        {
                            localId.UpdateModelPropertiesFrom(note);
                        }
                    }
                    else
                    {
                        localId.UpdateModelPropertiesFrom(note);
                        ClientCreditNoteHelper.SaveTransaction(note);
                    }
                }
            }
            else //  C2 -- El Idl no contenia un valor
            {
                if (localDE == null)
                {
                    db.ORIN_ClientCreditNotes.Add(note);
                    ClientCreditNoteHelper.SaveTransaction(note);
                }
            }

            //db.LOG_CHANGES.Add(changeset);
            changeset.AddChangeset();
        }
Beispiel #6
0
        // Common method   for View Modes.

        public static ORIN_ClientCreditNotes Synchronize(ORIN_ClientCreditNotes note)
        {
            CheckForUpdates();// Actualizar cambios antes de subir y verificar si el objeto no fue ya procesado
            note = ClientCreditNoteHelper.Get(note.IdClientCreditNoteL);
            if (note.StateL != LocalStatus.Procesado)
            {
                return(note.Upload(SyncUpload));
            }
            else
            {
                return(note);
            }
        }
        private void ProcessCreditNote()
        {
            IsBusy = IsDetailsBusy = true;

            if (!ConfirmDialog("Desea Procesar la Nota de Credito Seleccionada", "Procesar"))
            {
                IsBusy = IsDetailsBusy = false;
                return;
            }

            ShowProcessLoader(this);

            AsyncHelper.DoAsync(() =>
            {
                CreditNote.DocTotal = Total;
                //CreditNote.SeriesTitle = SelectedSerie.SeriesName + " " + SelectedSerie.Remark;
                CreditNote.RIN1_ClientCreditNoteDetail = CreditNoteDetailsCollection.ToList();

                if (CreditNote.IdClientCreditNoteL > 0)
                {
                    CreditNote.ModifiedDateL = DateTime.Now;
                    CreditNote.ModifiedByL   = Config.CurrentUser;
                    //CreditNote.StateL = LocalStatus.Pendiente;
                    ClientCreditNoteHelper.Update();
                    //RaisePropertyChanged("CreditNotesCollection");
                }
                else
                {
                    FillData();
                    //CreditNote.StateL = LocalStatus.Pendiente;
                    ClientCreditNoteHelper.Add(CreditNote);
                    // CreditNotesCollection.Add(CreditNote);
                }
                Synchronization.Synchronize(CreditNote);
                SaveChanges();

                IsDetailsBusy = IsBusy = false;
                RaisePropertyChanged("CreditNotesCollection");
            }, ViewModelManager.CloseProcessLoader);

            ViewModelManager.CloseModal();

            if (CreditNote.IdClientCreditNoteL == 0)
            {
                MessageBox.Show(
                    "La Nota de Crédito esta en proceso, por favor seleccione la pestaña NOTAS DE CRÉDITO para ver el detalle");
            }
        }
Beispiel #8
0
 public override bool CanExecuteNewCreditNote()
 {
     return(SelectedSale != null && SelectedSale.StateL == LocalStatus.Procesado && !ClientCreditNoteHelper.ExistCreditNote(SelectedSale));
 }