private void SetAccountSource(InvJournalLineGridClient rec) { SQLCache cache = (rec._MovementType == InvMovementType.Creditor) ? creditors : debtors; if (cache != null) { rec.accountSource = null; rec.NotifyPropertyChanged("AccountSource"); rec.accountSource = cache; rec.NotifyPropertyChanged("AccountSource"); } }
async void UnfoldBOM(InvJournalLineGridClient selectedItem) { var items = this.items; var item = (InvItem)items.Get(selectedItem._Item); if (item == null || item._ItemType != (byte)ItemType.ProductionBOM) { return; } busyIndicator.IsBusy = true; busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg"); var list = await api.Query <InvBOM>(selectedItem); if (list != null && list.Length > 0) { Array.Sort(list, new InvBOMSort()); var lst = new List <UnicontaBaseEntity>(list.Length); foreach (var bom in list) { var invJournalLine = new InvJournalLineGridClient(); invJournalLine._Item = bom._ItemPart; invJournalLine._Date = selectedItem._Date; invJournalLine._Dim1 = selectedItem._Dim1; invJournalLine._Dim2 = selectedItem._Dim2; invJournalLine._Dim3 = selectedItem._Dim3; invJournalLine._Dim4 = selectedItem._Dim4; invJournalLine._Dim5 = selectedItem._Dim5; invJournalLine._MovementType = InvMovementType.IncludedInBOM; 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.SetItemValues(item); invJournalLine._Warehouse = bom._Warehouse ?? item._Warehouse ?? selectedItem._Warehouse; invJournalLine._Location = bom._Location ?? item._Location ?? selectedItem._Location; invJournalLine._CostPrice = item._CostPrice; invJournalLine._Qty = -Math.Round(bom.GetBOMQty(selectedItem._Qty), item._Decimals); } else { invJournalLine._Qty = -Math.Round(bom.GetBOMQty(selectedItem._Qty), 2); } lst.Add(invJournalLine); } if (selectedItem._MovementType != InvMovementType.ReportAsFinished) { selectedItem._MovementType = InvMovementType.ReportAsFinished; selectedItem.NotifyPropertyChanged(nameof(selectedItem.MovementType)); } dgInvJournalLine.PasteRows(lst); this.DataChanged = true; } busyIndicator.IsBusy = false; }
async void setLocationTo(InvWarehouse master, InvJournalLineGridClient rec) { if (api.CompanyEntity.Location) { if (master != null) { rec.locationToSource = master.Locations ?? await master.LoadLocations(api); } else { rec.locationToSource = null; rec.LocationTo = null; } rec.NotifyPropertyChanged("LocationToSource"); } }
async void setSerieBatch(InvItem master, InvJournalLineGridClient rec) { if (master != null && master._UseSerialBatch) { var serie = new InvSerieBatchOpen() { _Item = rec._Item }; var lst = await api.Query <InvSerieBatchClient>(serie); rec.serieBatchSource = lst?.Select(x => x.Number).ToList(); } else { rec.serieBatchSource = null; rec.SerieBatch = null; } rec.NotifyPropertyChanged("SerieBatchSource"); }
async void GetItemFromSerailNumber(InvJournalLineGridClient rec) { var reportApi = new Uniconta.API.Inventory.ReportAPI(api); busyIndicator.IsBusy = true; var rowId = await reportApi.GetItemFromSerialNumber(rec.SerieBatch); busyIndicator.IsBusy = false; if (rowId == 0) { return; } var item = (InvItem)items.Get((int)rowId); if (item != null) { rec.Item = item._Item; rec.NotifyPropertyChanged("Item"); } }
async void setVariant(InvJournalLineGridClient rec, bool SetVariant2) { if (items == null || variants1 == null || variants2 == null) { return; } //Check for Variant2 Exist if (string.IsNullOrEmpty(api?.CompanyEntity?._Variant2)) { SetVariant2 = false; } var item = (InvItem)items.Get(rec._Item); if (item != null && item._StandardVariant != null) { rec.standardVariant = item._StandardVariant; var master = (InvStandardVariant)standardVariants?.Get(item._StandardVariant); if (master == null) { return; } if (master._AllowAllCombinations) { rec.Variant1Source = this.variants1?.GetKeyStrRecords.Cast <InvVariant1>(); rec.Variant2Source = this.variants2?.GetKeyStrRecords.Cast <InvVariant2>(); } else { var Combinations = master.Combinations ?? await master.LoadCombinations(api); if (Combinations == null) { return; } List <InvVariant1> invs1 = null; List <InvVariant2> invs2 = null; string vr1 = null; if (SetVariant2) { vr1 = rec._Variant1; invs2 = new List <InvVariant2>(); } else { invs1 = new List <InvVariant1>(); } string LastVariant = null; var var2Value = rec._Variant2; bool hasVariantValue = (var2Value == null); foreach (var cmb in Combinations) { if (SetVariant2) { if (cmb._Variant1 == vr1 && cmb._Variant2 != null) { var v2 = (InvVariant2)variants2.Get(cmb._Variant2); if (v2 != null) { invs2.Add(v2); if (var2Value == v2._Variant) { hasVariantValue = true; } } } } else if (LastVariant != cmb._Variant1) { LastVariant = cmb._Variant1; var v1 = (InvVariant1)variants1.Get(cmb._Variant1); if (v1 != null) { invs1.Add(v1); } } } if (SetVariant2) { rec.variant2Source = invs2; if (!hasVariantValue) { rec.Variant2 = null; } } else { rec.variant1Source = invs1; } } } else { rec.variant1Source = null; rec.variant2Source = null; } if (SetVariant2) { rec.NotifyPropertyChanged("Variant2Source"); } else { rec.NotifyPropertyChanged("Variant1Source"); } }