예제 #1
0
        void UpdatePrices()
        {
            var source = dgProjectJournalLinePageGrid.GetVisibleRows() as IEnumerable <ProjectJournalLineLocal>;

            foreach (var rec in source)
            {
                dgProjectJournalLinePageGrid.SetLoadedRow(rec);
                var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                if (pro != null)
                {
                    if (pro._Dim1 != null)
                    {
                        rec.Dimension1 = pro._Dim1;
                    }
                    if (pro._Dim2 != null)
                    {
                        rec.Dimension2 = pro._Dim2;
                    }
                    if (pro._Dim3 != null)
                    {
                        rec.Dimension3 = pro._Dim3;
                    }
                    if (pro._Dim4 != null)
                    {
                        rec.Dimension4 = pro._Dim4;
                    }
                    if (pro._Dim5 != null)
                    {
                        rec.Dimension5 = pro._Dim5;
                    }
                }

                rec.InsidePropChange = true;
                if (rec._Item != null)
                {
                    var cat = rec._PrCategory;
                    SetItem(rec);
                    SetCat(rec, cat);
                }

                getCostAndSales(rec);
                if (rec._Employee != null)
                {
                    TimePriceLookup?.GetEmployeePrice(rec);
                    var emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee);
                    if (emp?._PayrollCategory != null)
                    {
                        rec.InsidePropChange = false;
                        rec.PayrollCategory  = emp._PayrollCategory;
                    }
                }
                else if (rec._PayrollCategory != null)
                {
                    PayrollCat(rec, true);
                }

                dgProjectJournalLinePageGrid.SetModifiedRow(rec);
                rec.InsidePropChange = false;
            }
        }
예제 #2
0
        async void PayrollCat(ProjectBudgetLineLocal 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 (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)
            {
                if (rec._Qty == 0)
                {
                    rec.Qty = 1d;
                }
                rec.CostPrice = costPrice;
            }
            if (salesPrice != 0d)
            {
                if (rec._Qty == 0)
                {
                    rec.Qty = 1d;
                }
                rec.SalesPrice = salesPrice;
            }
        }
예제 #3
0
        private void SelectedItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var rec = (ProjectBudgetLineLocal)sender;

            switch (e.PropertyName)
            {
            case "Item":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    SetItem(rec);
                    rec.InsidePropChange = false;
                }
                break;

            case "Employee":
                if (rec._Employee != null)
                {
                    var emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee);
                    if (emp?._PayrollCategory != null)
                    {
                        rec.PayrollCategory = emp._PayrollCategory;
                    }
                    else if (!rec.InsidePropChange)
                    {
                        rec.InsidePropChange = true;
                        PayrollCat(rec, true);
                        rec.InsidePropChange = false;
                    }
                }
                break;

            case "PayrollCategory":
                if (rec._Employee != null && rec._PayrollCategory != null)
                {
                    if (!rec.InsidePropChange)
                    {
                        rec.InsidePropChange = true;
                        PayrollCat(rec, true);
                        rec.InsidePropChange = false;
                    }
                }
                break;

            case "TimeFrom":
            case "TimeTo":
                if (rec._ToTime >= rec._FromTime)
                {
                    rec.Qty = (rec._ToTime - rec._FromTime) / 60d;
                }
                break;

            case "Qty":
                if (rec._Qty != (rec._ToTime - rec._FromTime) / 60d)
                {
                    rec._FromTime = 0;
                    rec._ToTime   = 0;
                }
                break;

            case "CostPrice":
            case "SalesPrice":
                if (rec._Qty == 0d)
                {
                    rec.Qty = 1d;
                }
                break;
            }
        }
예제 #4
0
        private void SelectedItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var rec = (ProjectJournalLineLocal)sender;

            switch (e.PropertyName)
            {
            case "Item":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    SetItem(rec);
                    getCostAndSales(rec);
                    rec.InsidePropChange = false;
                }
                break;

            case "Project":
                var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                if (pro != null)
                {
                    if (pro._Dim1 != null)
                    {
                        rec.Dimension1 = pro._Dim1;
                    }
                    if (pro._Dim2 != null)
                    {
                        rec.Dimension2 = pro._Dim2;
                    }
                    if (pro._Dim3 != null)
                    {
                        rec.Dimension3 = pro._Dim3;
                    }
                    if (pro._Dim4 != null)
                    {
                        rec.Dimension4 = pro._Dim4;
                    }
                    if (pro._Dim5 != null)
                    {
                        rec.Dimension5 = pro._Dim5;
                    }
                    rec.Invoiceable = pro._InvoiceAble;
                    getCostAndSales(rec);
                    TimePriceLookup?.GetEmployeePrice(rec);
                    setTask(pro, rec);
                }
                break;

            case "PrCategory":
                getCostAndSales(rec);
                SetInvoiceable(rec);
                break;

            case "Employee":
                if (rec._Employee != null)
                {
                    var emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee);
                    if (emp?._PayrollCategory != null)
                    {
                        rec.PayrollCategory = emp._PayrollCategory;
                    }
                    if (!rec.InsidePropChange)
                    {
                        rec.InsidePropChange = true;
                        TimePriceLookup?.GetEmployeePrice(rec);
                        PayrollCat(rec, true);     //rec.InsidePropChange = false; done inside method
                    }
                }
                break;

            case "PayrollCategory":
                if (rec._Employee != null && rec._PayrollCategory != null)
                {
                    if (!rec.InsidePropChange)
                    {
                        rec.InsidePropChange = true;
                        TimePriceLookup?.GetEmployeePrice(rec);
                        PayrollCat(rec, true);     //rec.InsidePropChange = false; done inside method
                    }
                }
                break;

            case "Warehouse":
                if (WarehouseCache != null)
                {
                    var selected = (InvWarehouse)WarehouseCache.Get(rec._Warehouse);
                    setLocation(selected, rec);
                }
                break;

            case "Location":
                if (string.IsNullOrEmpty(rec._Warehouse))
                {
                    rec._Location = null;
                }
                break;

            case "TimeFrom":
            case "TimeTo":
                if (rec._TimeTo >= rec._TimeFrom)
                {
                    rec.Qty = (rec._TimeTo - rec._TimeFrom) / 60d;
                }
                else
                {
                    rec.Qty = ((rec._TimeTo + 24 * 60) - rec._TimeFrom) / 60d;
                }
                break;

            case "Qty":
                UpdatePrice(rec);
                double tim;
                if (rec._TimeTo >= rec._TimeFrom)
                {
                    tim = (rec._TimeTo - rec._TimeFrom) / 60d;
                }
                else
                {
                    tim = ((rec._TimeTo + 24 * 60) - rec._TimeFrom) / 60d;
                }

                if (rec._Qty != tim)
                {
                    rec._TimeFrom = 0;
                    rec._TimeTo   = 0;
                }
                break;

            case "EAN":
                FindOnEAN(rec);
                break;

            case "SerieBatch":
                if (ItemsCache != null)
                {
                    if (rec._Item == null || rec._Item == string.Empty)
                    {
                        GetItemFromSerailNumber(rec);
                    }
                }
                break;

            case "Task":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    if (rec._Task != null && rec._Project != null)
                    {
                        var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                        var task = proj.FindTask(rec._Task);
                        if (task != null)
                        {
                            rec.WorkSpace       = task._WorkSpace;
                            rec.PayrollCategory = task._PayrollCategory != null ? task._PayrollCategory : rec.PayrollCategory;
                        }
                    }
                    rec.InsidePropChange = false;
                }
                break;

            case "WorkSpace":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    if (rec._Task != null && rec._Project != null)
                    {
                        var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                        var task = proj.FindTask(rec._Task);
                        if (task != null && task._WorkSpace != rec._WorkSpace)
                        {
                            rec.Task = null;
                        }
                    }
                    rec.InsidePropChange = false;
                }
                break;
            }
        }