public override void ExecuteEdit() { ErrorMessage = string.Empty; SalesDetailsCollection = null; RaisePropertyChanged("SelectedSale"); if (SelectedSale != null) { UserIsValid = false; SelectedPartner = BusinessPartnerHelper.GetBusinessPartner(SelectedSale.CardCode); SelectedDownPayment = DownPaymentHelper.GetDownPaymentInSale(SelectedSale, asNotrack: true); HasDownPayment = SelectedDownPayment != null; Exento = SelectedSale.INV1_SalesDetail.Any(d => d.TaxCode == Config.IVAEXE); WithHolding = !Exento && SelectedSale.INV1_SalesDetail.Any(d => d.TaxCode == Config.IVARET); serie = SeriesHelper.GetSerie(selectedSale.Series); RaisePropertyChanged("Serie"); IsRoyality(); // Para actualizar existencias. var itemCodes = SelectedSale.INV1_SalesDetail.Select(d => d.ItemCode).ToList(); var inventory = ArticlesHelper.GetSalesArticles(itemCodes); SelectedSale.INV1_SalesDetail.ToList().ForEach(d => { var product = inventory.FirstOrDefault(p => p.ItemCode == d.ItemCode); if (product != null) { d.OnHand = ArticlesHelper.GetOnHandFor(product.ItemCode); // GetOnHandFromProduct(product); } }); } FormTitle = "Detalle de Venta " + SelectedSale.DocNum; ShowDialog(new SaleDetailsView(), this, resizeMode: ResizeMode.CanResize); }
void articleChooserViewModel_OnSelect(OITM_Articles obj) { IsModalVisible = false; var detail = new IGE1_GoodsIssueDetail() { ItemCode = obj.ItemCode, Quantity = ArticleChooserViewModel.Quantity, UnitMsr = obj.InvntryUom, AcctCode = obj.AccCount, // OITM_Articles = obj OnHand = ArticlesHelper.GetOnHandFor(obj.ItemCode), Dscription = obj.ItemName, }; ArticleChooserViewModel.CleanFields(); GoodsIssuesDetails.Add(detail); if (SelectedGoodsIssues != null) { SelectedGoodsIssues.IGE1_GoodsIssueDetail.Add(detail); } RaisePropertyChanged("GoodsIssuesDetails"); IsEnabled = GoodsIssuesDetails.Count == 0; }
//private decimal GetOnHandFromProduct(OITM_Articles product) //{ // var branchArticle = product.OITW_BranchArticles.Where(p => p.ItemCode == product.ItemCode) // .Select(p => p.OnHand1); // var onHand = branchArticle.Any() ? branchArticle.FirstOrDefault().Value : (decimal)0; // return onHand; //} private void GetSelectedArticle(OITM_Articles article) { IsModalVisible = false; if (SelectedSale == null) { SelectedSale = new OINV_Sales(); } if (SelectedSale == null) { return; } var detail = new INV1_SalesDetail() { ItemCode = article.ItemCode, Price = articleChooserViewModel.ProductPriceDecimal, Quantity = articleChooserViewModel.Quantity, LineTotal = articleChooserViewModel.TotalPriceToDecimal, //todo: OITM_Articles = article OnHand = ArticlesHelper.GetOnHandFor(article.ItemCode), // GetOnHandFromProduct(article), PriceEdited = article.PriceEdited, //TaxCode = SelectedSerie!=null && SelectedSerie.Series==43 ? "IVACOF":"IVACRF",// quemado por juan Dscription = article.ItemName, }; SelectedSale.INV1_SalesDetail.Add(detail); articleChooserViewModel.CleanFields(); detailsCollection.Add(detail); RaisePropertyChanged("SalesDetailsCollection"); IsFocusedAddButton = true; if (OnSelectedArticle != null) { OnSelectedArticle(); } }