async void setLocation(InvWarehouse master, CreditorOrderLineClient rec) { if (api.CompanyEntity.Location) { if (master != null) { rec.locationSource = master.Locations ?? await master.LoadLocations(api); } else { rec.locationSource = null; rec.Location = null; } rec.NotifyPropertyChanged("LocationSource"); } }
async void setTask(ProjectClient project, CreditorOrderLineClient rec) { if (api.CompanyEntity.ProjectTask) { if (project != null) { rec.taskSource = project.Tasks ?? await project.LoadTasks(api); } else { rec.taskSource = null; rec.Task = null; } rec.NotifyPropertyChanged("TaskSource"); } }
async void setVariant(CreditorOrderLineClient rec, bool SetVariant2) { if (items == null || variants1 == null || variants2 == null) { return; } //Check for Variant2 Exist if (api.CompanyEntity.NumberOfVariants < 2) { 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 = (IEnumerable <InvVariant1>) this.variants1?.GetKeyStrRecords; rec.Variant2Source = (IEnumerable <InvVariant2>) this.variants2?.GetKeyStrRecords; } 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); invs2.Add(v2); if (var2Value == v2._Variant) { hasVariantValue = true; } } } else if (LastVariant != cmb._Variant1) { LastVariant = cmb._Variant1; var v1 = (InvVariant1)variants1.Get(cmb._Variant1); 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"); } }