public override void RowPasted(UnicontaBaseEntity rec) { var Comp = api.CompanyEntity; var orderLine = rec as ProjectInvoiceProposalLineClient; if (orderLine == null) { return; } if (Comp._InvoiceUseQtyNow) { orderLine.QtyNow = orderLine._Qty; } if (orderLine._Item != null) { var selectedItem = (InvItem)items.Get(orderLine._Item); if (selectedItem != null) { PriceLookup?.SetPriceFromItem(orderLine, selectedItem); orderLine.SetItemValues(selectedItem, Comp._OrderLineStorage, true); TableField.SetUserFieldsFromRecord(selectedItem, orderLine); } else { orderLine._Item = null; } } }
async void SetValuesFromMaster(Debtor debtor) { if (debtor == null) { return; } var loadedOrder = LoadedRow as DCOrder; if (loadedOrder?._DCAccount == debtor._Account) { return; } editrow.Account = debtor._Account; editrow.SetCurrency(debtor._Currency); editrow.Payment = debtor._Payment; editrow.PricesInclVat = debtor._PricesInclVat; editrow.EndDiscountPct = debtor._EndDiscountPct; editrow.PostingAccount = debtor._PostingAccount; editrow.LayoutGroup = debtor._LayoutGroup; editrow.Shipment = debtor._Shipment; editrow.Employee = debtor._Employee; editrow.DeliveryTerm = debtor._DeliveryTerm; if (!RecordLoadedFromTemplate || debtor._DeliveryAddress1 != null) { editrow.DeliveryName = debtor._DeliveryName; editrow.DeliveryAddress1 = debtor._DeliveryAddress1; editrow.DeliveryAddress2 = debtor._DeliveryAddress2; editrow.DeliveryAddress3 = debtor._DeliveryAddress3; editrow.DeliveryZipCode = debtor._DeliveryZipCode; editrow.DeliveryCity = debtor._DeliveryCity; if (debtor._DeliveryCountry != 0) { editrow.DeliveryCountry = debtor._DeliveryCountry; } else { editrow.DeliveryCountry = null; } } TableField.SetUserFieldsFromRecord(debtor, editrow); if (ProjectCache != null) { Projectlookupeditor.cacheFilter = new DebtorProjectFilter(ProjectCache, debtor._Account); Projectlookupeditor.InvalidCache(); } BindContact(debtor); if (installationCache != null) { leDeliveryAddress.cacheFilter = new AccountCacheFilter(installationCache, 1, debtor._Account); leDeliveryAddress.InvalidCache(); } await api.Read(debtor); editrow.RefreshBalance(); }
async void SetFieldFromDebtor(DebtorOrderClient editrow, Debtor debtor) { if (debtor == null) { return; } var loadedOrder = LoadedRow as DCOrder; editrow.SetMaster(debtor); if (this.Project == null) // no project master { editrow.PricesInclVat = debtor._PricesInclVat; } if (!RecordLoadedFromTemplate || debtor._DeliveryAddress1 != null) { editrow.DeliveryName = debtor._DeliveryName; editrow.DeliveryAddress1 = debtor._DeliveryAddress1; editrow.DeliveryAddress2 = debtor._DeliveryAddress2; editrow.DeliveryAddress3 = debtor._DeliveryAddress3; editrow.DeliveryCity = debtor._DeliveryCity; if (editrow.DeliveryZipCode != debtor._DeliveryZipCode) { lookupZipCode = false; editrow.DeliveryZipCode = debtor._DeliveryZipCode; } if (debtor._DeliveryCountry != 0) { editrow.DeliveryCountry = debtor._DeliveryCountry; } else { editrow.DeliveryCountry = null; } } if (ProjectCache != null) { Projectlookupeditor.cache = ProjectCache; } TableField.SetUserFieldsFromRecord(debtor, editrow); BindContact(debtor); if (installationCache != null) { leDeliveryAddress.cacheFilter = new AccountCacheFilter(installationCache, 1, debtor._Account); leDeliveryAddress.InvalidCache(); } layoutItems.DataContext = null; layoutItems.DataContext = editrow; await api.Read(debtor); editrow.RefreshBalance(); }
private void leProdItem_SelectedIndexChanged(object sender, RoutedEventArgs e) { if (editrow.RowId == 0) { var item = leProdItem.SelectedItem as InvItem; if (item != null) { editrow.ProdQty = item._PurchaseQty; editrow.Warehouse = item._Warehouse; editrow.Location = item._Location; editrow.NotifyPropertyChanged("ProdQty"); TableField.SetUserFieldsFromRecord(item, editrow); } } }
public override void RowPasted(UnicontaBaseEntity rec) { var orderLine = (CreditorOrderLineClient)rec; if (orderLine._Item != null) { var selectedItem = (InvItem)items.Get(orderLine._Item); if (selectedItem != null) { PriceLookup?.SetPriceFromItem(orderLine, selectedItem); orderLine.SetItemValues(selectedItem, 0); TableField.SetUserFieldsFromRecord(selectedItem, orderLine); } else { orderLine._Item = null; } } }
async void SetValuesFromMaster(Uniconta.DataModel.Creditor creditor) { if (creditor == null) { return; } var loadedOrder = LoadedRow as DCOrder; if (loadedOrder?._DCAccount == creditor._Account) { return; } editrow.SetMaster(creditor); layoutItems.DataContext = null; layoutItems.DataContext = editrow; if (!RecordLoadedFromTemplate || creditor._DeliveryAddress1 != null) { editrow.DeliveryName = creditor._DeliveryName; editrow.DeliveryAddress1 = creditor._DeliveryAddress1; editrow.DeliveryAddress2 = creditor._DeliveryAddress2; editrow.DeliveryAddress3 = creditor._DeliveryAddress3; editrow.DeliveryCity = creditor._DeliveryCity; if (editrow.DeliveryZipCode != creditor._DeliveryZipCode) { lookupZipCode = false; editrow.DeliveryZipCode = creditor._DeliveryZipCode; } if (creditor._DeliveryCountry != 0) { editrow.DeliveryCountry = creditor._DeliveryCountry; } else { editrow.DeliveryCountry = null; } } TableField.SetUserFieldsFromRecord(creditor, editrow); BindContact(creditor); await api.Read(creditor); editrow.RefreshBalance(); }
private void ProductionOrderLineGrid_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var rec = (ProductionOrderLineClient)sender; switch (e.PropertyName) { case "Item": var selectedItem = (InvItem)items.Get(rec._Item); if (selectedItem != null) { rec.Text = selectedItem._Name; rec.NotifyPropertyChanged("Text"); TableField.SetUserFieldsFromRecord(selectedItem, rec); if (selectedItem._Blocked) { UtilDisplay.ShowErrorCode(ErrorCodes.ItemIsOnHold, null); } globalEvents?.NotifyRefreshViewer(NameOfControl, selectedItem); } break; case "Warehouse": if (warehouse != null) { var selected = (InvWarehouse)warehouse.Get(rec._Warehouse); setLocation(selected, (ProductionOrderLineClient)rec); } break; case "Location": if (string.IsNullOrEmpty(rec._Warehouse)) { rec._Location = null; } break; } }
private void ProductionMultiOrderLine_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var rec = sender as ProductionOrderLineClient; switch (e.PropertyName) { case "Item": if (items != null) { 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 lookup = SetPriceLookup(rec); if (lookup != null) { lookup.UseCustomerPrices = false; } if (selectedItem._SalesQty != 0d) { rec.Qty = selectedItem._SalesQty; } else if (api.CompanyEntity._PurchaseLineOne) { rec.Qty = 1d; } rec.SetItemValues(selectedItem, api.CompanyEntity._PurchaseLineStorage); if (lookup != null) { lookup.UseCustomerPrices = true; lookup.SetPriceFromItem(rec, selectedItem); } else if (selectedItem._PurchasePrice != 0) { rec.Price = selectedItem._PurchasePrice; } else { rec.Price = selectedItem._CostPrice; } TableField.SetUserFieldsFromRecord(selectedItem, rec); if (selectedItem._Blocked) { UtilDisplay.ShowErrorCode(ErrorCodes.ItemIsOnHold, null); } } } break; case "OrderNumber": var order = (ProductionOrder)productionOrders?.Get(NumberConvert.ToString(rec._OrderNumber)); if (order != null) { rec.SetMaster(order); SetPriceLookup(rec); } break; case "Qty": UpdatePrice(rec); break; case "Warehouse": if (warehouse != null) { var selected = (InvWarehouse)warehouse.Get(rec._Warehouse); SetLocation(selected, rec); } break; case "Location": if (string.IsNullOrEmpty(rec._Warehouse)) { rec._Location = null; } break; case "EAN": UnicontaClient.Pages.DebtorOfferLines.FindOnEAN(rec, this.items, api); break; case "Variant1": case "Variant2": case "Variant3": case "Variant4": case "Variant5": UpdatePrice(rec); break; } }
async void UnfoldBOM(ProductionOrderLineClient selectedItem) { var items = this.items; var item = (InvItem)items.Get(selectedItem._Item); if (item == null || item._ItemType < (byte)ItemType.BOM) { return; } busyIndicator.IsBusy = true; busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg"); var list = await api.Query <InvBOM>(selectedItem); if (list != null && list.Length > 0) { var type = dgProductionOrderLineGrid.TableTypeUser; var Qty = selectedItem._Qty; var lst = new List <UnicontaBaseEntity>(list.Length); foreach (var bom in list) { var invJournalLine = Activator.CreateInstance(type) as ProductionOrderLineClient; invJournalLine._Date = selectedItem._Date; invJournalLine._Week = selectedItem._Week; invJournalLine._Dim1 = selectedItem._Dim1; invJournalLine._Dim2 = selectedItem._Dim2; invJournalLine._Dim3 = selectedItem._Dim3; invJournalLine._Dim4 = selectedItem._Dim4; invJournalLine._Dim5 = selectedItem._Dim5; invJournalLine._Item = bom._ItemPart; invJournalLine._Variant1 = bom._Variant1; invJournalLine._Variant2 = bom._Variant2; invJournalLine._Variant3 = bom._Variant3; invJournalLine._Variant4 = bom._Variant4; invJournalLine._Variant5 = bom._Variant5; item = (InvItem)items.Get(bom._ItemPart); if (item == null && bom._ItemPart != null) { items = await api.LoadCache(typeof(InvItem), true); item = (InvItem)items.Get(bom._ItemPart); } if (item != null) { invJournalLine._Warehouse = bom._Warehouse ?? item._Warehouse ?? selectedItem._Warehouse; invJournalLine._Location = bom._Location ?? item._Location ?? selectedItem._Location; invJournalLine._CostPriceLine = item._CostPrice; invJournalLine.SetItemValues(item, selectedItem._Storage); invJournalLine._Qty = Math.Round(bom.GetBOMQty(Qty), item._Decimals); TableField.SetUserFieldsFromRecord(item, invJournalLine); } else { invJournalLine._Qty = Math.Round(bom.GetBOMQty(Qty), 2); } TableField.SetUserFieldsFromRecord(bom, invJournalLine); lst.Add(invJournalLine); } busyIndicator.IsBusy = false; dgProductionOrderLineGrid.ReplaceCurrentRow(lst); } busyIndicator.IsBusy = false; }
private void ProductionOrderLineGrid_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var rec = sender as ProductionOrderLineClient; switch (e.PropertyName) { case "Item": if (items != null) { 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; } } rec.SetItemValues(selectedItem, api.CompanyEntity._OrderLineStorage); rec.SetCostFromItem(selectedItem); rec.Price = selectedItem._CostPrice; double Qty; if (selectedItem._SalesQty != 0d) { Qty = selectedItem._SalesQty; } else if (api.CompanyEntity._OrderLineOne) { Qty = 1d; } else { Qty = 0d; } if (Order._ProdQty != 0d) { Qty *= Order._ProdQty; } rec.Qty = Qty; LoadInvItemStorageGrid(rec); TableField.SetUserFieldsFromRecord(selectedItem, rec); if (selectedItem._Blocked) { UtilDisplay.ShowErrorCode(ErrorCodes.ItemIsOnHold, null); } globalEvents?.NotifyRefreshViewer(NameOfControl, selectedItem); } } break; case "QtyDelivered": if (rec._QtyDelivered > rec._Qty) { UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("ValueMayNoBeGreater"), Uniconta.ClientTools.Localization.lookup("Consumed"), Uniconta.ClientTools.Localization.lookup("Qty")), Uniconta.ClientTools.Localization.lookup("Warning"), MessageBoxButton.OK); rec.QtyDelivered = rec._Qty; } break; case "Warehouse": if (warehouse != null) { var selected = (InvWarehouse)warehouse.Get(rec._Warehouse); setLocation(selected, rec); } break; case "Location": if (string.IsNullOrEmpty(rec._Warehouse)) { rec._Location = null; } break; case "EAN": UnicontaClient.Pages.DebtorOfferLines.FindOnEAN(rec, this.items, api); break; } }
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 DebtorOfferLineGrid_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var rec = sender as DebtorOfferLineClient; 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 if (selectedItem._SalesQty != 0d) { rec.Qty = selectedItem._SalesQty; } else if (api.CompanyEntity._OrderLineOne) { rec.Qty = 1d; } rec.SetItemValues(selectedItem); this.PriceLookup = _priceLookup; _priceLookup?.SetPriceFromItem(rec, selectedItem); 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); } globalEvents?.NotifyRefreshViewer(NameOfControl, selectedItem); } break; case "Qty": if (this.PriceLookup != null && this.PriceLookup.UseCustomerPrices) { this.PriceLookup.GetCustomerPrice(rec, false); } break; case "Subtotal": case "Total": RecalculateAmount(); break; case "Warehouse": if (warehouse != null) { var selected = (InvWarehouse)warehouse.Get(rec._Warehouse); setLocation(selected, rec); } break; case "Location": if (string.IsNullOrEmpty(rec._Warehouse)) { rec._Location = null; } break; case "Employee": if (rec._Employee != null) { var item = (InvItem)items?.Get(rec._Item); if (item == null || item._ItemType == (byte)Uniconta.DataModel.ItemType.Service) { var emp = (Uniconta.DataModel.Employee)employees?.Get(rec._Employee); if (emp != null && emp._CostPrice != 0d) { rec.CostPrice = emp._CostPrice; } } } break; case "EAN": FindOnEAN(rec, this.items, api, this.PriceLookup); 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; } }
async void UnfoldBOM(DebtorOfferLineClient selectedItem, bool usePriceFromBOM) { var items = this.items; var item = (InvItem)items.Get(selectedItem._Item); if (item == null || item._ItemType < (byte)ItemType.BOM) { return; } busyIndicator.IsBusy = true; busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg"); var list = await api.Query <InvBOM>(selectedItem); if (list != null && list.Length > 0) { var pl = this.PriceLookup; if (!usePriceFromBOM) { this.PriceLookup = null; } var type = dgDebtorOfferLineGrid.TableTypeUser; var Qty = selectedItem._Qty; var lst = new List <UnicontaBaseEntity>(list.Length); foreach (var bom in list) { var invJournalLine = Activator.CreateInstance(type) as DebtorOfferLineClient; invJournalLine._Date = selectedItem._Date; invJournalLine._Week = selectedItem._Week; invJournalLine._Dim1 = selectedItem._Dim1; invJournalLine._Dim2 = selectedItem._Dim2; invJournalLine._Dim3 = selectedItem._Dim3; invJournalLine._Dim4 = selectedItem._Dim4; invJournalLine._Dim5 = selectedItem._Dim5; invJournalLine._Item = bom._ItemPart; invJournalLine._Variant1 = bom._Variant1; invJournalLine._Variant2 = bom._Variant2; invJournalLine._Variant3 = bom._Variant3; invJournalLine._Variant4 = bom._Variant4; invJournalLine._Variant5 = bom._Variant5; item = (InvItem)items.Get(bom._ItemPart); if (item != null) { invJournalLine._Warehouse = bom._Warehouse ?? item._Warehouse ?? selectedItem._Warehouse; invJournalLine._Location = bom._Location ?? item._Location ?? selectedItem._Location; invJournalLine._CostPriceLine = item._CostPrice; invJournalLine.SetItemValues(item, selectedItem._Storage); invJournalLine._Qty = Math.Round(bom.GetBOMQty(Qty), item._Decimals); TableField.SetUserFieldsFromRecord(item, invJournalLine); } else { invJournalLine._Qty = Math.Round(bom.GetBOMQty(Qty), 2); } invJournalLine._Price = 0d; TableField.SetUserFieldsFromRecord(bom, invJournalLine); lst.Add(invJournalLine); } dgDebtorOfferLineGrid.PasteRows(lst); DataChaged = true; this.PriceLookup = pl; dgDebtorOfferLineGrid.SetLoadedRow(selectedItem); double _AmountEntered = 0d; if (!usePriceFromBOM) { _AmountEntered = selectedItem._Amount; } selectedItem.Price = 0; // will clear amountEntered if (!usePriceFromBOM) { selectedItem._AmountEntered = _AmountEntered; } selectedItem.Qty = 0; selectedItem.DiscountPct = 0; selectedItem.Discount = 0; selectedItem.CostPrice = 0; dgDebtorOfferLineGrid.SetModifiedRow(selectedItem); } busyIndicator.IsBusy = false; }