public TaxBucketsCalculation(string taxTypeForCalculation, PXGraph aGraph, RoundingManager rmanager, Currency aCurrency, CurrencyRateByDate curyRateByDate, Func <TaxReportLine, bool> showTaxReportLine) { taxType = taxTypeForCalculation; roundingManager = rmanager; graph = aGraph; currency = aCurrency; rateByDate = curyRateByDate; int curVendorBaccountID = roundingManager.CurrentVendor.BAccountID.Value; aggregatesTable = TaxReportMaint.AnalyseBuckets(graph, curVendorBaccountID, taxTypeForCalculation, CalcWithZones, showTaxReportLine); linesWithRelatedAggregatesTable = TransposeDictionary(aggregatesTable); }
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); }
public static PXResultset <TaxReportLine, TaxHistory> GetPreviewReport(PXGraph graph, Vendor vendor, PXResultset <TaxReportLine, TaxHistory> records, Func <TaxReportLine, bool> ShowTaxReportLine = null) { if (records.Count == 0) { return(records); } const bool calcWithZones = true; int vendorbAccountID = vendor.BAccountID.Value; RoundingManager rmanager = new RoundingManager(vendor); Dictionary <int, List <int> > taxAggregatesDict = TaxReportMaint.AnalyseBuckets(graph, vendorbAccountID, TaxReportLineType.TaxAmount, calcWithZones, ShowTaxReportLine) ?? new Dictionary <int, List <int> >(); Dictionary <int, List <int> > taxableAggregatesDict = TaxReportMaint.AnalyseBuckets(graph, vendorbAccountID, TaxReportLineType.TaxableAmount, calcWithZones, ShowTaxReportLine) ?? new Dictionary <int, List <int> >(); var recordsByLineNumberTable = new Dictionary <int, PXResult <TaxReportLine, TaxHistory> >(); foreach (PXResult <TaxReportLine, TaxHistory> record in records) { TaxReportLine taxLine = record; TaxHistory taxHistory = record; taxHistory.ReportUnfiledAmt = rmanager.Round(taxHistory.ReportUnfiledAmt); recordsByLineNumberTable[taxLine.LineNbr.Value] = record; } CalculateReportUnfiledAmtForAggregatedTaxLines(taxAggregatesDict, recordsByLineNumberTable); CalculateReportUnfiledAmtForAggregatedTaxLines(taxableAggregatesDict, recordsByLineNumberTable); return(records); }