示例#1
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();
        }
示例#2
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;
                }
            }
        }