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"); }
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; }
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); }