Пример #1
0
        public static void UpdateTaxHistorySums(PXGraph graph, RoundingManager rmanager, string taxPeriodId, int?revisionId, int?organizationID, int?branchID, Func <TaxReportLine, bool> ShowTaxReportLine = null)
        {
            if (!rmanager.IsRequireRounding)
            {
                return;
            }

            PXCache cache = graph.Caches[typeof(TaxHistory)];

            using (new PXReadBranchRestrictedScope(organizationID.SingleToArray(), branchID.SingleToArrayOrNull(), requireAccessForAllSpecified: true))
            {
                PXResultset <TaxHistory> lines = GetTaxHistoryLines(graph, rmanager.CurrentVendor.BAccountID, taxPeriodId, revisionId);

                if (lines.Count == 0)
                {
                    return;
                }

                if (organizationID == null)
                {
                    Branch branch = PXSelect <Branch, Where <Branch.branchID, Equal <Required <Branch.branchID> > > > .SelectSingleBound(graph, null, branchID);

                    organizationID = branch?.OrganizationID;
                }

                TaxPeriod period = TaxYearMaint.GetTaxPeriodByKey(graph, organizationID, rmanager.CurrentVendor.BAccountID,
                                                                  taxPeriodId);

                Company company = PXSelect <Company> .Select(graph);

                PXResult <Currency, CurrencyRateByDate> curyWithRateSet = GetCurrencyAndRateByDate(graph, rmanager.CurrentVendor, company, period);
                Currency           currency   = curyWithRateSet;
                CurrencyRateByDate rateByDate = currency.CuryID != company.BaseCuryID ? curyWithRateSet : null;

                TaxBucketsCalculation taxBucketsAggregatesCalc =
                    new TaxBucketsCalculation(TaxReportLineType.TaxAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine);

                TaxBucketsCalculation taxableBucketsAggregatesCalc =
                    new TaxBucketsCalculation(TaxReportLineType.TaxableAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine);

                taxBucketsAggregatesCalc.CalculateTaxBuckets(lines);
                taxableBucketsAggregatesCalc.CalculateTaxBuckets(lines);
            }

            cache.Persist(PXDBOperation.Insert);
            cache.Persisted(isAborted: false);
        }
        public static void UpdateTaxHistorySums(PXGraph graph, RoundingManager rmanager, string taxPeriodId, int?revisionId, int?branchID, Func <TaxReportLine, bool> ShowTaxReportLine = null)
        {
            if (!rmanager.IsRequireRounding)
            {
                return;
            }

            PXCache cache = graph.Caches[typeof(TaxHistory)];

            using (new PXReadBranchRestrictedScope(branchID))
            {
                PXResultset <TaxHistory> lines = GetTaxHistoryLines(graph, rmanager.CurrentVendor.BAccountID, taxPeriodId, revisionId);

                if (lines.Count == 0)
                {
                    return;
                }

                Branch branch = BranchMaint.FindBranchByID(graph, branchID);

                TaxPeriod period = TaxYearMaint.GetTaxPeriodByKey(graph, branch.ParentBranchID, rmanager.CurrentVendor.BAccountID,
                                                                  taxPeriodId);

                Company company = PXSelect <Company> .Select(graph);

                PXResult <Currency, CurrencyRateByDate> curyWithRateSet = GetCurrencyAndRateByDate(graph, rmanager.CurrentVendor, company, period);
                Currency           currency   = curyWithRateSet;
                CurrencyRateByDate rateByDate = currency.CuryID != company.BaseCuryID ? curyWithRateSet : null;

                TaxBucketsCalculation taxBucketsAggregatesCalc =
                    new TaxBucketsCalculation(TaxReportLineType.TaxAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine);

                TaxBucketsCalculation taxableBucketsAggregatesCalc =
                    new TaxBucketsCalculation(TaxReportLineType.TaxableAmount, graph, rmanager, currency, rateByDate, ShowTaxReportLine);

                taxBucketsAggregatesCalc.CalculateTaxBuckets(lines);
                taxableBucketsAggregatesCalc.CalculateTaxBuckets(lines);
            }

            cache.Persist(PXDBOperation.Insert);
            cache.Persisted(isAborted: false);
        }
Пример #3
0
 public TaxPeriod GetTaxPeriodByKey(int?branchID, int?taxAgencyID, string taxPeriodID)
 {
     return(TaxYearMaint.GetTaxPeriodByKey(_graph, branchID, taxAgencyID, taxPeriodID));
 }