public override void ExecuteNewCreditNote() { var cn = new ORIN_ClientCreditNotes() { CardCode = SelectedSale.CardCode, DocDate = SelectedSale.DocDate, Comments = SelectedSale.Comments, Series = 3, //serie correspondiente a nota de credito NumAtCard = SelectedSale.NumAtCard, DocTotal = SelectedSale.DocTotal, WhsCode = SelectedSale.WhsCode, PaymentTypeL = SelectedSale.PaymentType, CnTypeL = ClientCreditNoteType.Sale }; SalesDetailsCollection.ToList() .ForEach(pdc => { var article = ArticlesHelper.GetArticle(pdc.ItemCode); cn.RIN1_ClientCreditNoteDetail.Add( new RIN1_ClientCreditNoteDetail() { ItemCode = pdc.ItemCode, Quantity = pdc.Quantity, Price = pdc.Price, LineTotal = pdc.LineTotal, OITM_Articles = article, BaseDocNum = selectedSale.DocNum, BaseEntry = selectedSale.DocEntry, Dscription = article.ItemName, TaxCode = pdc.TaxCode, }); } ); var vm = new ClientCreditNoteViewModel { CreditNote = cn, FormTitle = "Nueva Nota de Crédito de Venta", //todo: reemplazar esto Exento = SelectedSale.INV1_SalesDetail.Any(d => d.TaxCode == Config.IVACOM), WithHolding = !Exento && SelectedSale.INV1_SalesDetail.Any(d => d.TaxCode == Config.IVARET), }; ShowDialog(new NewClientCreditNote(), vm); }
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); }
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(); }