Ejemplo n.º 1
0
 void SetCat(ProjectJournalLineLocal rec, string cat)
 {
     if (cat != null && cat != rec._PrCategory)
     {
         rec.PrCategory = cat;
         SetInvoiceable(rec);
     }
 }
Ejemplo n.º 2
0
        void SetItem(ProjectJournalLineLocal rec)
        {
            var item = (InvItem)ItemsCache.Get(rec._Item);

            if (item == null)
            {
                return;
            }

            SetPriceLookup(rec)?.SetPriceFromItem(rec, item);

            if (item._Dim1 != null)
            {
                rec.Dimension1 = item._Dim1;
            }
            if (item._Dim2 != null)
            {
                rec.Dimension2 = item._Dim2;
            }
            if (item._Dim3 != null)
            {
                rec.Dimension3 = item._Dim3;
            }
            if (item._Dim4 != null)
            {
                rec.Dimension4 = item._Dim4;
            }
            if (item._Dim5 != null)
            {
                rec.Dimension5 = item._Dim5;
            }
            if (item._Warehouse != null)
            {
                rec.Warehouse = item._Warehouse;
            }
            if (item._Location != null)
            {
                rec.Location = item._Location;
            }

            SetCat(rec, item._PrCategory);
            if (item._PayrollCategory != null)
            {
                rec.PayrollCategory = item._PayrollCategory;
                if (rec._SalesPrice == 0d)
                {
                    PayrollCat(rec, false);
                    TimePriceLookup?.GetEmployeePrice(rec);
                }
            }
            if (item._Unit != 0 && rec._Unit != item._Unit)
            {
                rec._Unit = item._Unit;
                rec.NotifyPropertyChanged("Unit");
            }

            globalEvents?.NotifyRefreshViewer(NameOfControl, item);
        }
Ejemplo n.º 3
0
        void UpdatePrice(ProjectJournalLineLocal rec)
        {
            var priceLookup = SetPriceLookup(rec);

            if (priceLookup != null && priceLookup.UseCustomerPrices)
            {
                priceLookup.GetCustomerPrice(rec, false);
            }
        }
Ejemplo n.º 4
0
        private void SerieBatch_GotFocus(object sender, RoutedEventArgs e)
        {
            ProjectJournalLineLocal selectedItem = dgProjectJournalLinePageGrid.SelectedItem as ProjectJournalLineLocal;

            if (selectedItem?._Item != null)
            {
                setSerieBatch(ItemsCache.Get <InvItem>(selectedItem._Item), selectedItem);
            }
        }
Ejemplo n.º 5
0
        void SetInvoiceable(ProjectJournalLineLocal rec)
        {
            var Cat = (PrCategory)CategoryCache.Get(rec._PrCategory);

            if (Cat != null)
            {
                rec.Invoiceable = Cat._Invoiceable;
            }
        }
Ejemplo n.º 6
0
        async void UnfoldBOM(ProjectJournalLineLocal selectedItem)
        {
            var items = this.ItemsCache;
            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)
            {
                Array.Sort(list, new InvBOMSort());
                var lst = new List <UnicontaBaseEntity>(list.Length);
                foreach (var bom in list)
                {
                    item = (InvItem)items.Get(bom._ItemPart);
                    if (item == null)
                    {
                        continue;
                    }
                    var invJournalLine = new ProjectJournalLineLocal();
                    invJournalLine._Item = bom._ItemPart;
                    invJournalLine.SetItemValues(item);
                    invJournalLine._Project         = selectedItem._Project;
                    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._Employee        = selectedItem._Employee;
                    invJournalLine._Task            = selectedItem._Task;
                    invJournalLine._Variant1        = bom._Variant1;
                    invJournalLine._Variant2        = bom._Variant2;
                    invJournalLine._Variant3        = bom._Variant3;
                    invJournalLine._Variant4        = bom._Variant4;
                    invJournalLine._Variant5        = bom._Variant5;
                    invJournalLine._PrCategory      = item._PrCategory ?? selectedItem._PrCategory;
                    invJournalLine._PayrollCategory = item._PayrollCategory ?? selectedItem._PayrollCategory;
                    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);
                    lst.Add(invJournalLine);
                }
                dgProjectJournalLinePageGrid.PasteRows(lst);
                this.DataChanged = true;
            }
            busyIndicator.IsBusy = false;
        }
        public override void SetDefaultValues(UnicontaBaseEntity dataEntity, int selectedIndex)
        {
            var newRow = (ProjectJournalLineLocal)dataEntity;
            var header = this.masterRecord as Uniconta.DataModel.PrJournal;

            if (header != null)
            {
                newRow.SetMaster(header);
                newRow._Dim1      = header._Dim1;
                newRow._Dim2      = header._Dim2;
                newRow._Dim3      = header._Dim3;
                newRow._Dim4      = header._Dim4;
                newRow._Dim5      = header._Dim5;
                newRow._Employee  = header._Employee;
                newRow._TransType = header._TransType;
            }

            var lst = (IList)this.ItemsSource;

            if (lst == null || lst.Count == 0)
            {
                newRow._Date = BasePage.GetSystemDefaultDate().Date;
            }
            else
            {
                ProjectJournalLineLocal last = null;
                ProjectJournalLineLocal Cur  = null;
                int      n            = -1;
                DateTime LastDateTime = DateTime.MinValue;
                var      castItem     = lst as IEnumerable <ProjectJournalLineLocal>;
                foreach (var journalLine in castItem)
                {
                    if (journalLine._Date != DateTime.MinValue && Cur == null)
                    {
                        LastDateTime = journalLine._Date;
                    }
                    n++;
                    if (n == selectedIndex)
                    {
                        Cur = journalLine;
                    }
                    last = journalLine;
                }
                if (Cur == null)
                {
                    Cur = last;
                }

                newRow._Date            = LastDateTime != DateTime.MinValue ? LastDateTime : BasePage.GetSystemDefaultDate().Date;
                newRow._Project         = last._Project;
                newRow._PrCategory      = last._PrCategory;
                newRow._Invoiceable     = last._Invoiceable;
                newRow.PrCategorySource = last.PrCategorySource;
            }
        }
Ejemplo n.º 8
0
        async void getCostAndSales(ProjectJournalLineLocal rec)
        {
            var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);

            if (proj == null)
            {
                return;
            }

            var Categories = proj.Categories ?? await proj.LoadCategories(api);

            rec.costPct = 0d; rec.salesPct = 0d; rec.costAmount = 0d; rec.salesAmount = 0d;
            if (Categories == null)
            {
                return;
            }

            var Category = rec._PrCategory;
            var projCat  = (from ct in Categories where ct._PrCategory == Category select ct).FirstOrDefault();

            if (projCat != null)
            {
                rec.costPct     = projCat._CostPctCharge;
                rec.salesPct    = projCat._SalesPctCharge;
                rec.costAmount  = projCat._CostAmountCharge;
                rec.salesAmount = projCat._SalesAmountCharge;
            }
            else
            {
                var prstd = (PrStandard)PrStandardCache.Get(proj._PrStandard);
                if (prstd == null)
                {
                    return;
                }
                var PrCategories = prstd.Categories ?? await prstd.LoadCategories(api);

                if (PrCategories == null)
                {
                    return;
                }

                var prCat = (from ct in PrCategories where ct._PrCategory == Category select ct).FirstOrDefault();
                if (prCat != null)
                {
                    rec.costPct     = prCat._CostPctCharge;
                    rec.salesPct    = prCat._SalesPctCharge;
                    rec.costAmount  = prCat._CostAmountCharge;
                    rec.salesAmount = prCat._SalesAmountCharge;
                }
            }
        }
 async void setTask(Uniconta.DataModel.Project project, ProjectJournalLineLocal 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");
     }
 }
Ejemplo n.º 10
0
 async void setLocation(InvWarehouse master, ProjectJournalLineLocal 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");
     }
 }
Ejemplo n.º 11
0
        private void DataControl_CurrentItemChanged(object sender, DevExpress.Xpf.Grid.CurrentItemChangedEventArgs e)
        {
            ProjectJournalLineLocal oldselectedItem = e.OldItem as ProjectJournalLineLocal;

            if (oldselectedItem != null)
            {
                oldselectedItem.PropertyChanged -= SelectedItem_PropertyChanged;
            }

            ProjectJournalLineLocal selectedItem = e.NewItem as ProjectJournalLineLocal;

            if (selectedItem != null)
            {
                selectedItem.InsidePropChange = false;
                selectedItem.PropertyChanged += SelectedItem_PropertyChanged;
            }
        }
Ejemplo n.º 12
0
        void PayrollCat(ProjectJournalLineLocal rec, bool AddItem)
        {
            var pay = (Uniconta.DataModel.EmpPayrollCategory)PayrollCache?.Get(rec._PayrollCategory);

            if (pay != null)
            {
                if (pay._Unit != 0 && rec._Unit != pay._Unit)
                {
                    rec._Unit = pay._Unit;
                    rec.NotifyPropertyChanged("Unit");
                }

                if (pay._PrCategory != null)
                {
                    rec.PrCategory = pay._PrCategory;
                }

                if (pay._Dim1 != null)
                {
                    rec.Dimension1 = pay._Dim1;
                }
                if (pay._Dim2 != null)
                {
                    rec.Dimension2 = pay._Dim2;
                }
                if (pay._Dim3 != null)
                {
                    rec.Dimension3 = pay._Dim3;
                }
                if (pay._Dim4 != null)
                {
                    rec.Dimension4 = pay._Dim4;
                }
                if (pay._Dim5 != null)
                {
                    rec.Dimension5 = pay._Dim5;
                }

                if (AddItem && pay._Item != null)
                {
                    rec.Item = pay._Item;
                }
            }
            rec.InsidePropChange = false;
        }
Ejemplo n.º 13
0
        async void setSerieBatch(InvItem master, ProjectJournalLineLocal rec)
        {
            if (master != null && master._UseSerialBatch)
            {
                var lst = await api.Query <InvSerieBatchClient>(new InvSerieBatchOpen()
                {
                    _Item = rec._Item
                });

                rec.serieBatchSource = lst?.Select(x => x.Number).ToList();
            }
            else
            {
                rec.serieBatchSource = null;
                rec.SerieBatch       = null;
            }
            rec.NotifyPropertyChanged("SerieBatchSource");
        }
Ejemplo n.º 14
0
        async void setTask(Uniconta.DataModel.Project project, ProjectJournalLineLocal rec)
        {
            if (api.CompanyEntity.ProjectTask)
            {
                if (project != null)
                {
                    var tasks = project.Tasks ?? await project.LoadTasks(api);

                    rec.taskSource = tasks?.Where(s => s.Ended == false && (rec._WorkSpace == null || s._WorkSpace == rec._WorkSpace));
                }
                else
                {
                    rec.taskSource = null;
                    rec.Task       = null;
                }
                rec.NotifyPropertyChanged("TaskSource");
            }
        }
Ejemplo n.º 15
0
        async void GetItemFromSerailNumber(ProjectJournalLineLocal 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)ItemsCache.Get((int)rowId);

            if (item != null)
            {
                rec.Item = item._Item;
                rec.NotifyPropertyChanged("Item");
            }
        }
Ejemplo n.º 16
0
        void FindOnEAN(ProjectJournalLineLocal rec)
        {
            var EAN = rec._EAN;

            if (string.IsNullOrWhiteSpace(EAN))
            {
                return;
            }
            var found = (from item in (InvItem[])ItemsCache.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);
            }
        }
Ejemplo n.º 17
0
        async void FindOnEANVariant(ProjectJournalLineLocal rec)
        {
            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;
                }
            }
        }
Ejemplo n.º 18
0
        Uniconta.API.DebtorCreditor.FindPrices SetPriceLookup(ProjectJournalLineLocal rec)
        {
            var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);

            if (proj != null)
            {
                if (dictPriceLookup.ContainsKey(proj._DCAccount))
                {
                    return(dictPriceLookup[proj._DCAccount]);
                }

                var order = new DebtorOrder()
                {
                    _DCAccount = proj._DCAccount
                };
                var priceLookup = new Uniconta.API.DebtorCreditor.FindPrices(order, api);
                dictPriceLookup.Add(proj._DCAccount, priceLookup);
                return(priceLookup);
            }
            return(null);
        }
        async void PayrollCat(ProjectJournalLineLocal rec, bool AddItem)
        {
            double costPrice = 0, salesPrice = 0;
            var    emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee);

            if (emp != null)
            {
                costPrice  = emp._CostPrice;
                salesPrice = emp._SalesPrice;
            }

            var pay = (Uniconta.DataModel.EmpPayrollCategory)PayrollCache?.Get(rec._PayrollCategory);

            if (pay != null)
            {
                if (pay._Unit != 0 && rec._Unit != pay._Unit)
                {
                    rec._Unit = pay._Unit;
                    rec.NotifyPropertyChanged("Unit");
                }
                if (AddItem && !pay._Invoiceable)
                {
                    rec.Invoiceable = false;
                }

                if (pay._PrCategory != null)
                {
                    rec.PrCategory = pay._PrCategory;
                }

                if (pay._Rate != 0)
                {
                    costPrice = pay._Rate;
                }
                if (pay._SalesPrice != 0)
                {
                    salesPrice = pay._SalesPrice;
                }

                string Item = pay._Item;
                if (pay._Dim1 != null)
                {
                    rec.Dimension1 = pay._Dim1;
                }
                if (pay._Dim2 != null)
                {
                    rec.Dimension2 = pay._Dim2;
                }
                if (pay._Dim3 != null)
                {
                    rec.Dimension3 = pay._Dim3;
                }
                if (pay._Dim4 != null)
                {
                    rec.Dimension4 = pay._Dim4;
                }
                if (pay._Dim5 != null)
                {
                    rec.Dimension5 = pay._Dim5;
                }

                if (emp != null)
                {
                    Uniconta.DataModel.EmpPayrollCategoryEmployee found = null;
                    var Rates = pay.Rates ?? await pay.LoadRates(api);

                    foreach (var rate in Rates)
                    {
                        if (rate._ValidFrom != DateTime.MinValue && rate._ValidFrom > rec._Date)
                        {
                            continue;
                        }
                        if (rate._ValidTo != DateTime.MinValue && rate._ValidTo < rec._Date)
                        {
                            continue;
                        }
                        if (rate._Employee != emp._Number)
                        {
                            continue;
                        }
                        if (rate._Project != null)
                        {
                            if (rate._Project == rec._Project)
                            {
                                found = rate;
                                break;
                            }
                        }
                        else if (found == null)
                        {
                            found = rate;
                        }
                    }

                    if (found != null)
                    {
                        if (found._CostPrice != 0d)
                        {
                            costPrice = found._CostPrice;
                        }
                        else if (found._Rate != 0d)
                        {
                            costPrice = found._Rate;
                        }
                        if (found._SalesPrice != 0d)
                        {
                            salesPrice = found._SalesPrice;
                        }
                        if (found._Item != null)
                        {
                            Item = found._Item;
                        }

                        if (found._Dim1 != null)
                        {
                            rec.Dimension1 = found._Dim1;
                        }
                        if (found._Dim2 != null)
                        {
                            rec.Dimension2 = found._Dim2;
                        }
                        if (found._Dim3 != null)
                        {
                            rec.Dimension3 = found._Dim3;
                        }
                        if (found._Dim4 != null)
                        {
                            rec.Dimension4 = found._Dim4;
                        }
                        if (found._Dim5 != null)
                        {
                            rec.Dimension5 = found._Dim5;
                        }
                    }
                }

                if (AddItem && Item != null)
                {
                    rec.Item = Item;
                }
            }
            if (costPrice != 0d)
            {
                rec.SetCost(costPrice);
            }
            if (salesPrice != 0d)
            {
                rec.SetSales(salesPrice);
            }

            rec.InsidePropChange = false;
        }