示例#1
0
 private void SetPrCategorySource(ProjectInvoiceProjectLineLocal rec)
 {
     if (CategoryCache != null && CategoryCache.Count != 0)
     {
         rec._prCategorySource = new PrCategoryRegulationFilter(CategoryCache);
         rec.NotifyPropertyChanged("ProjectCategorySource");
     }
 }
示例#2
0
        public override void SetDefaultValues(UnicontaBaseEntity dataEntity, int selectedIndex)
        {
            var newRow = (ProjectInvoiceProjectLineLocal)dataEntity;
            var header = this.masterRecord as Uniconta.DataModel.DebtorOrder;

            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
            {
                ProjectInvoiceProjectLineLocal last = null;
                ProjectInvoiceProjectLineLocal Cur  = null;
                int      n            = -1;
                DateTime LastDateTime = DateTime.MinValue;
                var      castItem     = lst as IEnumerable <ProjectInvoiceProjectLineLocal>;
                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.PrCategorySource = last.PrCategorySource;
            }
        }
示例#3
0
        async void getCostAndSales(ProjectInvoiceProjectLineLocal rec)
        {
            var project = rec._Project;

            if (project == null)
            {
                return;
            }
            var proj       = (Uniconta.DataModel.Project)ProjectCache.Get(project);
            var Categories = proj.Categories ?? await proj.LoadCategories(api);

            rec.costPct = 0d; rec.salesPct = 0d; rec.costAmount = 0d; rec.salesAmount = 0d;

            var Category = rec._PrCategory;

            var prcategory = (Uniconta.DataModel.PrCategory)CategoryCache.Get(Category);

            if (prcategory != null && prcategory._Forward)
            {
                rec.ProjectForward = invoiceProposal._Project;
            }

            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);

                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;
                }
            }
            RecalculateAmount();
        }
示例#4
0
        private void DataControl_CurrentItemChanged(object sender, DevExpress.Xpf.Grid.CurrentItemChangedEventArgs e)
        {
            ProjectInvoiceProjectLineLocal oldselectedItem = e.OldItem as ProjectInvoiceProjectLineLocal;

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

            ProjectInvoiceProjectLineLocal selectedItem = e.NewItem as ProjectInvoiceProjectLineLocal;

            if (selectedItem != null)
            {
                selectedItem.InsidePropChange = false;
                selectedItem.PropertyChanged += SelectedItem_PropertyChanged;
            }
        }
示例#5
0
        Uniconta.API.DebtorCreditor.FindPrices SetPriceLookup(ProjectInvoiceProjectLineLocal 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);
        }
示例#6
0
        void SetItem(ProjectInvoiceProjectLineLocal 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._PrCategory != null)
            {
                rec.PrCategory = item._PrCategory;
            }
        }
示例#7
0
 void UpdatePrice(ProjectInvoiceProjectLineLocal rec)
 {
     var priceLookup = SetPriceLookup(rec);
     //if (priceLookup != null && priceLookup.UseCustomerPrices)
     //    priceLookup.GetCustomerPrice(rec, false);
 }
示例#8
0
        async void AdjustTransactionPerEmployee()
        {
            // var propValuePair = new List<PropValuePair>() { PropValuePair.GenereteWhereElements("SendToOrder", invoiceProposal._OrderNumber, CompareOperator.Equal) };
            var trans = await api.Query <ProjectTransClient>(invoiceProposal);

            if (trans != null)
            {
                int n;
                ProjectTransClient t;
                double             Amountsum = 0;
                for (n = 0; (n < trans.Length); n++)
                {
                    t = trans[n];
                    if (t._Employee != null && t._PrCategory != null && ((PrCategory)CategoryCache.Get(t._PrCategory))._CatType == CategoryType.Labour)
                    {
                        Amountsum += t._SalesAmount;
                    }
                    else
                    {
                        trans[n] = null;
                    }
                }
                double     adjustment         = invoiceProposal._OrderTotal - invoiceProposal._ProjectTotal;
                PrCategory adjustmentcategory = null;
                foreach (var cat in (Uniconta.DataModel.PrCategory[])CategoryCache.GetNotNullArray)
                {
                    if (cat._CatType == CategoryType.Adjustment)
                    {
                        adjustmentcategory = cat;
                        break;
                    }
                }

                // we need to delete all rows in grid
                dgProjInvProjectLineGrid.DeleteAllRows();

                // Now all lines are deleted (not in SQL, just in corasauDataGrid)
                // Now we will insert new lines in corasauDataGrid
                // On 'save' old lines will be delete and new lines added.

                double adjustmentAdded = 0;
                int    pos             = 0;
                ProjectInvoiceProjectLineLocal line = null;
                for (n = 0; (n < trans.Length); n++)
                {
                    t = trans[n];
                    if (t != null)
                    {
                        var price = Math.Round(adjustment / Amountsum * t._SalesAmount, 2);
                        adjustmentAdded += price;
                        line             = ((IEnumerable <ProjectInvoiceProjectLineLocal>)dgProjInvProjectLineGrid.ItemsSource).Where(e => e.Employee == t.Employee).FirstOrDefault();
                        if (line == null)
                        {
                            line             = new ProjectInvoiceProjectLineLocal();
                            line.PrCategory  = adjustmentcategory?.KeyStr;
                            line._Qty        = 1;
                            line._SalesPrice = price;
                            line._Employee   = t._Employee;
                            line._Dim1       = t._Dim1;
                            line._Dim2       = t._Dim2;
                            line._Dim3       = t._Dim3;
                            line._Dim4       = t._Dim4;
                            line._Dim5       = t._Dim5;
                            dgProjInvProjectLineGrid.InsertRow(line, pos++);
                        }
                        else
                        {
                            line.SalesPrice += price;
                        }
                    }
                }
                if (line != null)
                {
                    line.SalesPrice += (adjustment - adjustmentAdded);
                }

                dgProjInvProjectLineGrid.ShowTotalSummary();
                RecalculateAmount();
            }
        }