void SetupMaster(UnicontaBaseEntity args) { dcorderlineMaster = args as DCOrderLineClient; invItemMaster = itemCache.Get(dcorderlineMaster._Item) as InvItem; dgLinkedGrid.invItemMaster = invItemMaster; dgLinkedGrid.dcorderlineMaster = dcorderlineMaster; }
public Task SetPriceFromItem(DCOrderLineClient orderLine, InvItem item) { Task t = _SetPriceFromItem(orderLine, item, 0d, 0d); Task t2 = null; if (this.UseCustomerPrices && this._PriceList != null && orderLine._Item != null) { t2 = GetCustomerPrice(orderLine, true); } if (t2 == null) { return(t); } else if (t == null) { return(t2); } else if (t.IsCompleted) { return(t2); } else if (t2.IsCompleted) { return(t); } else #if !SILVERLIGHT { return(Task.WhenAll(new Task[] { t, t2 })); } #else { return(t2); } #endif }
void InitPage(UnicontaBaseEntity master) { InitializeComponent(); dcorderlineMaster = master as DCOrderLineClient; Comp = api.CompanyEntity; api.AllowBackgroundCrud = true; itemCache = Comp.GetCache(typeof(InvItem)); invItemMaster = itemCache.Get(dcorderlineMaster._Item) as InvItem; SetRibbonControl(localMenu, dgLinkedGrid); dgLinkedGrid.invItemMaster = invItemMaster; dgLinkedGrid.dcorderlineMaster = dcorderlineMaster; dgLinkedGrid.api = api; dgUnlinkedGrid.api = api; dgLinkedGrid.BusyIndicator = busyIndicator; dgUnlinkedGrid.BusyIndicator = busyIndicator; dgLinkedGrid.SelectedItemChanged += DgLinkedGrid_SelectedItemChanged; localMenu.OnItemClicked += localMenu_OnItemClicked; if (dcorderlineMaster.__DCType() != 2) { RemoveMenuItem(); } if (Comp.Warehouse) { warehouse = Comp.GetCache(typeof(InvWarehouse)); } ribbonControl.lowerSearchGrid = dgUnlinkedGrid; ribbonControl.UpperSearchNullText = Uniconta.ClientTools.Localization.lookup("Link"); ribbonControl.LowerSearchNullText = Uniconta.ClientTools.Localization.lookup("Unlinked"); }
private async void LookRate(DCOrderLineClient rec, double price, byte From, byte To) { var Rate = await api.session.ExchangeRate((Currencies)From, (Currencies)To, BasePage.GetSystemDefaultDate(), api.CompanyEntity); rec.Price = (Rate == 0d) ? price : Math.Round(price * Rate, 2); }
static async void FindOnEANVariant(DCOrderLineClient rec, QueryAPI api, Uniconta.API.DebtorCreditor.FindPrices PriceLookup) { if (PriceLookup != null && PriceLookup.UseCustomerPrices) { var found = await PriceLookup.GetCustomerPriceFromEAN(rec); if (found) { return; } } var ap = new Uniconta.API.Inventory.ReportAPI(api); var variant = await ap.GetInvVariantDetail(rec._EAN); if (variant != null) { rec.Item = variant._Item; rec.Variant1 = variant._Variant1; rec.Variant2 = variant._Variant2; rec.Variant3 = variant._Variant3; rec.Variant4 = variant._Variant4; rec.Variant5 = variant._Variant5; rec._EAN = variant._EAN; if (variant._CostPrice != 0d) { rec._CostPrice = variant._CostPrice; } } }
public ItemVariantAddPage(DCOrderLineClient line, DCOrder master) : base(null) { this.master = master; this.line = line; this.invItem = line.InvItem; InitPage(); }
public CreditorOrderLineMarkedPage(UnicontaBaseEntity orderLine) : base(null) { InitializeComponent(); ((TableView)dgCreditorOrderLineGrid.View).RowStyle = Application.Current.Resources["StyleRow"] as Style; debtorOrderLine = orderLine as DCOrderLineClient; orderRefLine = debtorOrderLine.OrderRefLine; SetHeader(); dgCreditorOrderLineGrid.api = api; localMenu.dataGrid = dgCreditorOrderLineGrid; SetRibbonControl(localMenu, dgCreditorOrderLineGrid); dgCreditorOrderLineGrid.BusyIndicator = busyIndicator; dgCreditorOrderLineGrid.Readonly = true; localMenu.OnItemClicked += LocalMenu_OnItemClicked; }
public InventoryTransactionsMarkedPage(UnicontaBaseEntity orderLine) : base(null) { this.DataContext = this; InitializeComponent(); debtorOrderLine = orderLine as DCOrderLineClient; if (debtorOrderLine != null) { Item = debtorOrderLine._Item; DCType = debtorOrderLine.__DCType(); this.qty = debtorOrderLine._Qty; costRefTrans = debtorOrderLine.CostRefTrans; if (DCType == 2) { dcaccount = ((CreditorOrderLineClient)debtorOrderLine).Order?._DCAccount; } else if (DCType == 4) { dcaccount = ((ProductionOrderLineClient)debtorOrderLine).Production?._DCAccount; } else { dcaccount = ((DebtorOrderLineClient)debtorOrderLine).Order?._DCAccount; } } else { invtrans = orderLine as InvTrans; if (invtrans != null) { Item = invtrans._Item; DCType = invtrans._MovementType; this.qty = invtrans._Qty; dcaccount = invtrans._DCAccount; if (DCType != 2 && this.qty < 0) { this.qty = -this.qty; } } } SetHeader(); dgInvTransGrid.api = api; localMenu.dataGrid = dgInvTransGrid; SetRibbonControl(localMenu, dgInvTransGrid); dgInvTransGrid.BusyIndicator = busyIndicator; dgInvTransGrid.Readonly = true; dgInvTransGrid.CustomSummary += DgInvTransGrid_CustomSummary; dgInvTransGrid.ShowTotalSummary(); localMenu.OnItemClicked += LocalMenu_OnItemClicked; }
public static async void FindItemFromCustomerItem(DCOrderLineClient rec, DCOrder order, QueryAPI api, string CustomerItemNumber) { var ap = new Uniconta.API.Inventory.ReportAPI(api); var variant = await ap.FindItemFromCustomerItem(order, CustomerItemNumber); if (variant != null) { rec.Item = variant._Item; rec.Variant1 = variant._Variant1; rec.Variant2 = variant._Variant2; rec.Variant3 = variant._Variant3; rec.Variant4 = variant._Variant4; rec.Variant5 = variant._Variant5; } }
public InventoryTransactionsMarkedPage(UnicontaBaseEntity orderLine) : base(null) { this.DataContext = this; InitializeComponent(); debtorOrderLine = orderLine as DCOrderLineClient; costRefTrans = debtorOrderLine.CostRefTrans; SetHeader(); dgInvTransGrid.api = api; localMenu.dataGrid = dgInvTransGrid; SetRibbonControl(localMenu, dgInvTransGrid); dgInvTransGrid.BusyIndicator = busyIndicator; dgInvTransGrid.Readonly = true; dgInvTransGrid.CustomSummary += DgInvTransGrid_CustomSummary; dgInvTransGrid.ShowTotalSummary(); localMenu.OnItemClicked += LocalMenu_OnItemClicked; }
static public void FindOnEAN(DCOrderLineClient rec, SQLCache Items, QueryAPI api, Uniconta.API.DebtorCreditor.FindPrices PriceLookup) { var EAN = rec._EAN; if (string.IsNullOrWhiteSpace(EAN)) { return; } var found = (from item in (InvItem[])Items.GetNotNullArray where string.Compare(item._EAN, EAN, StringComparison.CurrentCultureIgnoreCase) == 0 select item).FirstOrDefault(); if (found != null) { rec._EAN = found._EAN; rec.Item = found._Item; } else { FindOnEANVariant(rec, api, PriceLookup); } }
static async void FindOnEANVariant(DCOrderLineClient rec, QueryAPI api) { var ap = new Uniconta.API.Inventory.ReportAPI(api); var variant = await ap.GetInvVariantDetail(rec._EAN); if (variant != null) { rec.Item = variant._Item; rec.Variant1 = variant._Variant1; rec.Variant2 = variant._Variant2; rec.Variant3 = variant._Variant3; rec.Variant4 = variant._Variant4; rec.Variant5 = variant._Variant5; rec._EAN = variant._EAN; if (variant._CostPrice != 0d) { rec._CostPrice = variant._CostPrice; } } }
public ItemVariantAddPage(DCOrderLineClient line, DCOrder master) : base(null) { DataContext = this; InitializeComponent(); localMenu.dataGrid = dgItemVariant; dgItemVariant.api = api; SetRibbonControl(localMenu, dgItemVariant); dgItemVariant.BusyIndicator = busyIndicator; this.master = master; this.line = line; this.invItem = line.InvItem; var standardVariants = api.GetCache(typeof(Uniconta.DataModel.InvStandardVariant)); stdVariant = (InvStandardVariant)standardVariants?.Get(invItem._StandardVariant); if (stdVariant != null) { VariantSetup(colVariant1, colVariant2, colVariant3, colVariant4, colVariant5, stdVariant); } localMenu.OnItemClicked += localMenu_OnItemClicked; }
Task _SetPriceFromItem(DCOrderLineClient orderLine, InvItem item, double LineMarginRatio, double LineSalesCharge) { Task t = null; byte priceCurrency = item._Currency1; var price = item._SalesPrice1; var costprice = item._CostPrice; var unit = item._SalesUnit; var MarginRatio = this.MarginRatio; if (LineMarginRatio > 0d) { MarginRatio = LineMarginRatio; } if (orderLine.__DCType() == 2) { unit = item._PurchaseUnit; if (item._PurchasePrice != 0d) { price = item._PurchasePrice; priceCurrency = item._PurchaseCurrency; } else { price = costprice; priceCurrency = 0; } } else if (MarginRatio > 0d && MarginRatio < 100d) { priceCurrency = 0; var margin = costprice * MarginRatio / (100d - MarginRatio); price = Math.Round(costprice + margin, RoundMargin ? 0 : 2) + SalesCharge + LineSalesCharge; } else { var pg = this.PriceGrp; if (pg == 0) { if (OrderCurrency == item._Currency2) { pg = 2; } else if (OrderCurrency == item._Currency3) { pg = 3; } } if (pg == 2) { priceCurrency = item._Currency2; price = item._SalesPrice2; } else if (pg == 3) { priceCurrency = item._Currency3; price = item._SalesPrice3; } } if (OrderCurrency != priceCurrency) { if (priceCurrency == 0) { priceCurrency = CompCurrency; } if (OrderCurrency != priceCurrency) { if (priceCurrency == CompCurrency) { price = (ExchangeRate == 0d) ? price : Math.Round(price * ExchangeRate, 2); } else { t = LookRate(orderLine, price, priceCurrency, OrderCurrency); price = 0; } } } if (orderLine.__DCType() != 2) { orderLine.SetCostFromItem(item); } if (price != 0) { orderLine.Price = price; } if (unit != 0) { orderLine._Unit = unit; orderLine.NotifyPropertyChanged("Unit"); } return(t); }
public async Task GetCustomerPrice(DCOrderLineClient orderLine, bool IsNewItem) { if (!this.UseCustomerPrices) { return; } var t = LoadingTask; if (t != null && !t.IsCompleted) { await t; } if (this._PriceList == null || orderLine._Item == null) { return; } var itemRec = (InvItem)items.Get(orderLine._Item); if (itemRec == null) { return; } orderLine._Qty = Math.Round(orderLine._Qty, itemRec._Decimals); if (CustomerPrices == null) { await loadPriceList(); } if (CustomerPrices == null) { return; } var len = CustomerPrices.Length; var searchrec = new InvPriceListLine(); searchrec._DCType = debtor.__DCType(); searchrec._Item = orderLine._Item; // Do not include Variant, since we also want to finde prices without variant //searchrec._Variant1 = orderLine._Variant1; //searchrec._Variant2 = orderLine._Variant2; searchrec._prioritet = int.MinValue; var pos = search(searchrec); var now = OrderTime; int FoundPriority = -1; bool HasQtyPrices = false; int CurVariantMatch = -1; InvPriceListLine rec = null; var qty = Math.Abs(orderLine._Qty) + 0.00000000001d; while (pos < len) { var r = CustomerPrices[pos++]; var c = string.Compare(r._Item, orderLine._Item); if (c != 0) { break; } if ((r._ValidFrom != DateTime.MinValue && now < r._ValidFrom) || (r._ValidTo != DateTime.MinValue && now > r._ValidTo)) { continue; } int VariantMatch = VariantCompare(orderLine._Variant1, r._Variant1); if (VariantMatch >= 0) { int VariantMatch2 = VariantCompare(orderLine._Variant2, r._Variant2); if (VariantMatch2 >= 0) { VariantMatch += VariantMatch2; if (VariantMatch >= CurVariantMatch) { if (r._Qty != 0d) { HasQtyPrices = true; } if (r._Qty <= qty) { bool UseMatch = true; if (r._FirstMatch) { if (FoundPriority == -1) { FoundPriority = r._prioritet; } else if (FoundPriority != r._prioritet) { UseMatch = false; } } if (UseMatch) { rec = r; CurVariantMatch = VariantMatch; } } } } } } CurVariantMatch = 0; searchrec._Item = null; searchrec._Variant1 = null; searchrec._Variant2 = null; if (rec == null && itemRec._DiscountGroup != null) { var discountgroup = itemRec._DiscountGroup; searchrec._DiscountGroup = discountgroup; pos = search(searchrec); while (pos < len) { var r = CustomerPrices[pos++]; int c = string.Compare(r._DiscountGroup, discountgroup); if (c != 0) { break; } if ((r._ValidFrom != DateTime.MinValue && now < r._ValidFrom) || (r._ValidTo != DateTime.MinValue && now > r._ValidTo)) { continue; } if (r._Qty != 0d) { HasQtyPrices = true; } if (r._Qty <= qty) { rec = r; } } } if (rec == null && itemRec._Group != null) { var group = itemRec._Group; searchrec._ItemGroup = group; searchrec._DiscountGroup = null; pos = search(searchrec); while (pos < len) { var r = CustomerPrices[pos++]; int c = string.Compare(r._ItemGroup, group); if (c != 0) { break; } if ((r._ValidFrom != DateTime.MinValue && now < r._ValidFrom) || (r._ValidTo != DateTime.MinValue && now > r._ValidTo)) { continue; } if (r._Qty != 0d) { HasQtyPrices = true; } if (r._Qty <= qty) { rec = r; } } } if (rec != null && (IsNewItem || HasQtyPrices || CurVariantMatch >= 0)) { if (rec._Pct != 0d) { orderLine.DiscountPct = rec._Pct; } if (rec._Discount != 0d) { orderLine.Discount = rec._Discount; } if (rec._Unit != 0) { orderLine._Unit = rec._Unit; orderLine.NotifyPropertyChanged("Unit"); } if (rec._Price != 0d) { var price = rec._Price; if (OrderCurrency != PriceListCurrency) { if (PriceListCurrency == CompCurrency) { price = (ExchangeRate == 0d) ? price : Math.Round(price * ExchangeRate, 2); } else { await LookRate(orderLine, price, PriceListCurrency, OrderCurrency); return; } } orderLine.Price = price; } if (!rec._FixedContributionRate) { return; } } var task = _SetPriceFromItem(orderLine, (InvItem)items.Get(orderLine._Item), rec != null ? rec._ContributionRate : 0d, rec != null ? rec._SalesCharge : 0d); if (task != null) { await task; } }
private async Task LookRate(DCOrderLineClient rec, double price, byte From, byte To) { var Rate = await api.session.ExchangeRate((Currencies)From, (Currencies)To, DateTime.Now, api.CompanyEntity); rec.Price = (Rate == 0d) ? price : Math.Round(price * Rate, 2); }
static public void FindOnEAN(DCOrderLineClient rec, SQLCache Items, QueryAPI api) { FindOnEAN(rec, Items, api, null); }