Example #1
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;
        }
Example #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;
            }
        }