void UpdatePrices() { var source = dgProjectJournalLinePageGrid.GetVisibleRows() as IEnumerable <ProjectJournalLineLocal>; foreach (var rec in source) { dgProjectJournalLinePageGrid.SetLoadedRow(rec); var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); if (pro != null) { if (pro._Dim1 != null) { rec.Dimension1 = pro._Dim1; } if (pro._Dim2 != null) { rec.Dimension2 = pro._Dim2; } if (pro._Dim3 != null) { rec.Dimension3 = pro._Dim3; } if (pro._Dim4 != null) { rec.Dimension4 = pro._Dim4; } if (pro._Dim5 != null) { rec.Dimension5 = pro._Dim5; } } rec.InsidePropChange = true; if (rec._Item != null) { var cat = rec._PrCategory; SetItem(rec); SetCat(rec, cat); } getCostAndSales(rec); if (rec._Employee != null) { TimePriceLookup?.GetEmployeePrice(rec); var emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee); if (emp?._PayrollCategory != null) { rec.InsidePropChange = false; rec.PayrollCategory = emp._PayrollCategory; } } else if (rec._PayrollCategory != null) { PayrollCat(rec, true); } dgProjectJournalLinePageGrid.SetModifiedRow(rec); rec.InsidePropChange = false; } }
private void Task_GotFocus(object sender, RoutedEventArgs e) { var selectedItem = dgProjectJournalLinePageGrid.SelectedItem as ProjectJournalLineLocal; if (selectedItem?._Project != null) { setTask((Uniconta.DataModel.Project)ProjectCache.Get(selectedItem._Project), selectedItem); } }
private void SelectedItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var rec = (ProjectInvoiceProjectLineLocal)sender; switch (e.PropertyName) { case "Item": if (!rec.InsidePropChange) { rec.InsidePropChange = true; SetItem(rec); getCostAndSales(rec); rec.InsidePropChange = false; } break; case "Project": var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); if (pro != null) { if (pro._Dim1 != null) { rec.Dimension1 = pro._Dim1; } if (pro._Dim2 != null) { rec.Dimension2 = pro._Dim2; } if (pro._Dim3 != null) { rec.Dimension3 = pro._Dim3; } if (pro._Dim4 != null) { rec.Dimension4 = pro._Dim4; } if (pro._Dim5 != null) { rec.Dimension5 = pro._Dim5; } getCostAndSales(rec); } break; case "PrCategory": getCostAndSales(rec); break; case "Qty": UpdatePrice(rec); break; } RecalculateAmount(); }
void UpdatePrices() { var source = dgDebtorOrderProjectLineGrid.GetVisibleRows() as IEnumerable <DebtorOrderProjectLineLocal>; foreach (var rec in source) { dgDebtorOrderProjectLineGrid.SetLoadedRow(rec); var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); if (pro != null) { if (pro._Dim1 != null) { rec.Dimension1 = pro._Dim1; } if (pro._Dim2 != null) { rec.Dimension2 = pro._Dim2; } if (pro._Dim3 != null) { rec.Dimension3 = pro._Dim3; } if (pro._Dim4 != null) { rec.Dimension4 = pro._Dim4; } if (pro._Dim5 != null) { rec.Dimension5 = pro._Dim5; } } rec.InsidePropChange = true; if (rec._Item != null) { var cat = rec._PrCategory; SetItem(rec); if (cat != null) { rec.PrCategory = cat; } } else { getCostAndSales(rec); } dgDebtorOrderProjectLineGrid.SetModifiedRow(rec); rec.InsidePropChange = false; } }
async void getCostAndSales(ProjectInvoiceProjectLineLocal rec) { var project = rec._Project; if (project == null) { return; } var proj = (Uniconta.DataModel.Project)ProjectCache.Get(project); var Categories = proj.Categories ?? await proj.LoadCategories(api); rec.costPct = 0d; rec.salesPct = 0d; rec.costAmount = 0d; rec.salesAmount = 0d; var Category = rec._PrCategory; var prcategory = (Uniconta.DataModel.PrCategory)CategoryCache.Get(Category); if (prcategory != null && prcategory._Forward) { rec.ProjectForward = invoiceProposal._Project; } var projCat = (from ct in Categories where ct._PrCategory == Category select ct).FirstOrDefault(); if (projCat != null) { rec.costPct = projCat._CostPctCharge; rec.salesPct = projCat._SalesPctCharge; rec.costAmount = projCat._CostAmountCharge; rec.salesAmount = projCat._SalesAmountCharge; } else { var prstd = (PrStandard)PrStandardCache.Get(proj._PrStandard); if (prstd == null) { return; } var PrCategories = prstd.Categories ?? await prstd.LoadCategories(api); var prCat = (from ct in PrCategories where ct._PrCategory == Category select ct).FirstOrDefault(); if (prCat != null) { rec.costPct = prCat._CostPctCharge; rec.salesPct = prCat._SalesPctCharge; rec.costAmount = prCat._CostAmountCharge; rec.salesAmount = prCat._SalesAmountCharge; } } RecalculateAmount(); }
async void getCostAndSales(ProjectJournalLineLocal rec) { var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); if (proj == null) { return; } var Categories = proj.Categories ?? await proj.LoadCategories(api); rec.costPct = 0d; rec.salesPct = 0d; rec.costAmount = 0d; rec.salesAmount = 0d; if (Categories == null) { return; } var Category = rec._PrCategory; var projCat = (from ct in Categories where ct._PrCategory == Category select ct).FirstOrDefault(); if (projCat != null) { rec.costPct = projCat._CostPctCharge; rec.salesPct = projCat._SalesPctCharge; rec.costAmount = projCat._CostAmountCharge; rec.salesAmount = projCat._SalesAmountCharge; } else { var prstd = (PrStandard)PrStandardCache.Get(proj._PrStandard); if (prstd == null) { return; } var PrCategories = prstd.Categories ?? await prstd.LoadCategories(api); if (PrCategories == null) { return; } var prCat = (from ct in PrCategories where ct._PrCategory == Category select ct).FirstOrDefault(); if (prCat != null) { rec.costPct = prCat._CostPctCharge; rec.salesPct = prCat._SalesPctCharge; rec.costAmount = prCat._CostAmountCharge; rec.salesAmount = prCat._SalesAmountCharge; } } }
private void Task_GotFocus(object sender, RoutedEventArgs e) { var selectedItem = dgCreditorOrderLineGrid.SelectedItem as CreditorOrderLineClient; if (selectedItem?._Project != null) { var selected = (ProjectClient)ProjectCache.Get(selectedItem._Project); setTask(selected, selectedItem); if (prevTask != null) { prevTask.isValidate = false; } var editor = (CorasauGridLookupEditorClient)sender; prevTask = editor; editor.isValidate = true; } }
Uniconta.API.DebtorCreditor.FindPrices SetPriceLookup(DebtorOrderProjectLineLocal rec) { var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); if (proj != null) { if (dictPriceLookup.ContainsKey(proj._DCAccount)) { return(dictPriceLookup[proj._DCAccount]); } var order = new DebtorOrder() { _DCAccount = proj._DCAccount }; var priceLookup = new Uniconta.API.DebtorCreditor.FindPrices(order, api); dictPriceLookup.Add(proj._DCAccount, priceLookup); return(priceLookup); } return(null); }
private void SelectedItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var rec = sender as CreditorOrderLineClient; switch (e.PropertyName) { case "Item": var selectedItem = (InvItem)items?.Get(rec._Item); if (selectedItem != null) { if (selectedItem._AlternativeItem != null && selectedItem._UseAlternative == UseAlternativeItem.Always) { var altItem = (InvItem)items.Get(selectedItem._AlternativeItem); if (altItem != null && altItem._AlternativeItem == null) { rec.Item = selectedItem._AlternativeItem; return; } } var _priceLookup = this.PriceLookup; this.PriceLookup = null; // avoid that we call priceupdated in property change on Qty var Comp = api.CompanyEntity; if (selectedItem._PurchaseQty != 0d) { rec.Qty = selectedItem._PurchaseQty; } else if (Comp._PurchaseLineOne) { rec.Qty = 1d; } rec.SetItemValues(selectedItem, Comp._PurchaseLineStorage); if (_priceLookup != null) { this.PriceLookup = _priceLookup; _priceLookup.SetPriceFromItem(rec, selectedItem); } else if (selectedItem._PurchasePrice != 0 && Comp.SameCurrency(selectedItem._PurchaseCurrency, (byte)this.Order._Currency)) { rec.Price = selectedItem._PurchasePrice; } else { rec.Price = (exchangeRate == 0d) ? selectedItem._CostPrice : Math.Round(selectedItem._CostPrice * exchangeRate, 2); } if (selectedItem._StandardVariant != rec.standardVariant) { rec.Variant1 = null; rec.Variant2 = null; rec.variant2Source = null; rec.NotifyPropertyChanged("Variant2Source"); } setVariant(rec, false); TableField.SetUserFieldsFromRecord(selectedItem, rec); if (selectedItem._Blocked) { UtilDisplay.ShowErrorCode(ErrorCodes.ItemIsOnHold, null); } } break; case "Qty": if (this.PriceLookup != null && this.PriceLookup.UseCustomerPrices) { this.PriceLookup.GetCustomerPrice(rec, false); } break; case "Warehouse": if (warehouse != null) { var selected = (InvWarehouse)warehouse.Get(rec._Warehouse); setLocation(selected, (CreditorOrderLineClient)rec); } break; case "Location": if (string.IsNullOrEmpty(rec._Warehouse)) { rec._Location = null; } break; case "EAN": DebtorOfferLines.FindOnEAN(rec, this.items, api, this.PriceLookup); break; case "Total": RecalculateAmount(); break; case "Variant1": if (rec._Variant1 != null) { setVariant(rec, true); } if (this.PriceLookup != null && this.PriceLookup.UseCustomerPrices) { this.PriceLookup.GetCustomerPrice(rec, false); } break; case "Variant2": case "Variant3": case "Variant4": case "Variant5": if (this.PriceLookup != null && this.PriceLookup.UseCustomerPrices) { this.PriceLookup.GetCustomerPrice(rec, false); } break; case "Project": if (ProjectCache != null) { var selected = (ProjectClient)ProjectCache.Get(rec._Project); setTask(selected, rec); } break; case "Task": if (string.IsNullOrEmpty(rec._Project)) { rec._Task = null; } break; } }
private void SelectedItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var rec = (ProjectJournalLineLocal)sender; switch (e.PropertyName) { case "Item": if (!rec.InsidePropChange) { rec.InsidePropChange = true; SetItem(rec); getCostAndSales(rec); rec.InsidePropChange = false; } break; case "Project": var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); if (pro != null) { if (pro._Dim1 != null) { rec.Dimension1 = pro._Dim1; } if (pro._Dim2 != null) { rec.Dimension2 = pro._Dim2; } if (pro._Dim3 != null) { rec.Dimension3 = pro._Dim3; } if (pro._Dim4 != null) { rec.Dimension4 = pro._Dim4; } if (pro._Dim5 != null) { rec.Dimension5 = pro._Dim5; } rec.Invoiceable = pro._InvoiceAble; getCostAndSales(rec); TimePriceLookup?.GetEmployeePrice(rec); setTask(pro, rec); } break; case "PrCategory": getCostAndSales(rec); SetInvoiceable(rec); break; case "Employee": if (rec._Employee != null) { var emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee); if (emp?._PayrollCategory != null) { rec.PayrollCategory = emp._PayrollCategory; } if (!rec.InsidePropChange) { rec.InsidePropChange = true; TimePriceLookup?.GetEmployeePrice(rec); PayrollCat(rec, true); //rec.InsidePropChange = false; done inside method } } break; case "PayrollCategory": if (rec._Employee != null && rec._PayrollCategory != null) { if (!rec.InsidePropChange) { rec.InsidePropChange = true; TimePriceLookup?.GetEmployeePrice(rec); PayrollCat(rec, true); //rec.InsidePropChange = false; done inside method } } break; case "Warehouse": if (WarehouseCache != null) { var selected = (InvWarehouse)WarehouseCache.Get(rec._Warehouse); setLocation(selected, rec); } break; case "Location": if (string.IsNullOrEmpty(rec._Warehouse)) { rec._Location = null; } break; case "TimeFrom": case "TimeTo": if (rec._TimeTo >= rec._TimeFrom) { rec.Qty = (rec._TimeTo - rec._TimeFrom) / 60d; } else { rec.Qty = ((rec._TimeTo + 24 * 60) - rec._TimeFrom) / 60d; } break; case "Qty": UpdatePrice(rec); double tim; if (rec._TimeTo >= rec._TimeFrom) { tim = (rec._TimeTo - rec._TimeFrom) / 60d; } else { tim = ((rec._TimeTo + 24 * 60) - rec._TimeFrom) / 60d; } if (rec._Qty != tim) { rec._TimeFrom = 0; rec._TimeTo = 0; } break; case "EAN": FindOnEAN(rec); break; case "SerieBatch": if (ItemsCache != null) { if (rec._Item == null || rec._Item == string.Empty) { GetItemFromSerailNumber(rec); } } break; case "Task": if (!rec.InsidePropChange) { rec.InsidePropChange = true; if (rec._Task != null && rec._Project != null) { var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); var task = proj.FindTask(rec._Task); if (task != null) { rec.WorkSpace = task._WorkSpace; rec.PayrollCategory = task._PayrollCategory != null ? task._PayrollCategory : rec.PayrollCategory; } } rec.InsidePropChange = false; } break; case "WorkSpace": if (!rec.InsidePropChange) { rec.InsidePropChange = true; if (rec._Task != null && rec._Project != null) { var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project); var task = proj.FindTask(rec._Task); if (task != null && task._WorkSpace != rec._WorkSpace) { rec.Task = null; } } rec.InsidePropChange = false; } break; } }