public static Dictionary <int, List <int> > AnalyseBuckets(PXGraph graph, int BAccountID, string TaxLineType, bool CalcWithZones, Func <TaxReportLine, bool> ShowTaxReportLine = null)
        {
            TaxBucketAnalizer analizer = new TaxBucketAnalizer(graph, BAccountID, TaxLineType);

            if (ShowTaxReportLine != null)
            {
                analizer.showTaxReportLine = ShowTaxReportLine;
            }
            return(analizer.AnalyzeBuckets(CalcWithZones));
        }
Exemple #2
0
        protected IEnumerable reportLine()
        {
            if (TaxVendor.Current.BAccountID == null)
            {
                yield break;
            }

            bool showTaxZones = TaxVendor.Current.ShowNoTemp == true;
            TaxBucketAnalizer             analyzerTax         = new TaxBucketAnalizer(this, TaxVendor.Current.BAccountID.Value, TaxReportLineType.TaxAmount);
            Dictionary <int, List <int> > taxBucketsDict      = analyzerTax.AnalyzeBuckets(showTaxZones);
            TaxBucketAnalizer             testAnalyzerTaxable = new TaxBucketAnalizer(this, (int)this.TaxVendor.Current.BAccountID, TaxReportLineType.TaxableAmount);
            Dictionary <int, List <int> > taxableBucketsDict  = testAnalyzerTaxable.AnalyzeBuckets(showTaxZones);

            Dictionary <int, List <int> >[] bucketsArr = { taxBucketsDict, taxableBucketsDict };

            Dictionary <int, TaxReportLine> taxReporLinesByLineNumber =
                PXSelect <TaxReportLine,
                          Where <TaxReportLine.vendorID, Equal <Current <VendorMaster.bAccountID> >,
                                 And <
                                     Where2 <
                                         Where <Current <VendorMaster.showNoTemp>, Equal <False>,
                                                And <TaxReportLine.tempLineNbr, IsNull> >,
                                         Or <
                                             Where <Current <VendorMaster.showNoTemp>, Equal <True>,
                                                    And <
                                                        Where <TaxReportLine.tempLineNbr, IsNull,
                                                               And <TaxReportLine.tempLine, Equal <False>,
                                                                    Or <TaxReportLine.tempLineNbr, IsNotNull> > > > > > > > >,
                          OrderBy <
                              Asc <TaxReportLine.sortOrder,
                                   Asc <TaxReportLine.taxZoneID> > > >
                .Select(this)
                .RowCast <TaxReportLine>()
                .ToDictionary(taxLine => taxLine.LineNbr.Value);

            foreach (TaxReportLine taxline in taxReporLinesByLineNumber.Values)
            {
                if (!showTaxZones)
                {
                    foreach (Dictionary <int, List <int> > bucketsDict in bucketsArr.Where(dict => dict?.ContainsKey(taxline.LineNbr.Value) == true))
                    {
                        var calcRuleWithLineNumberReplacedBySortOrder =
                            bucketsDict[taxline.LineNbr.Value].Where(lineNbr => taxReporLinesByLineNumber.ContainsKey(lineNbr))
                            .Select(lineNbr => taxReporLinesByLineNumber[lineNbr].SortOrder.Value)
                            .OrderBy(lineNbr => lineNbr);

                        taxline.BucketSum = string.Join("+", calcRuleWithLineNumberReplacedBySortOrder);
                    }
                }

                yield return(taxline);
            }
        }
            public static void CheckTaxAgencySettings(PXGraph graph, int BAccountID)
            {
                PXResultset <TaxBucket> buckets = PXSelect <TaxBucket, Where <TaxBucket.vendorID, Equal <Required <TaxBucket.vendorID> > > > .Select(graph, BAccountID);

                if (buckets == null)
                {
                    return;
                }
                TaxBucketAnalizer taxAnalizer     = new TaxBucketAnalizer(graph, BAccountID, TaxReportLineType.TaxAmount);
                TaxBucketAnalizer taxableAnalizer = new TaxBucketAnalizer(graph, BAccountID, TaxReportLineType.TaxableAmount);

                foreach (TaxBucket bucket in buckets)
                {
                    taxAnalizer.DoChecks((int)bucket.BucketID);
                    taxableAnalizer.DoChecks((int)bucket.BucketID);
                }
            }
        protected IEnumerable reportLine()
        {
            if (this.TaxVendor.Current.BAccountID == null)
            {
                yield break;
            }
            bool showTaxZones = TaxVendor.Current.ShowNoTemp == true;
            TaxBucketAnalizer             AnalyzerTax         = new TaxBucketAnalizer(this, (int)this.TaxVendor.Current.BAccountID, TaxReportLineType.TaxAmount);
            Dictionary <int, List <int> > taxBucketsDict      = AnalyzerTax.AnalyzeBuckets(showTaxZones);
            TaxBucketAnalizer             TestAnalyzerTaxable = new TaxBucketAnalizer(this, (int)this.TaxVendor.Current.BAccountID, TaxReportLineType.TaxableAmount);
            Dictionary <int, List <int> > taxableBucketsDict  = TestAnalyzerTaxable.AnalyzeBuckets(showTaxZones);

            Dictionary <int, List <int> >[] bucketsArr = { taxBucketsDict, taxableBucketsDict };
            StringBuilder sb = new StringBuilder();

            foreach (TaxReportLine taxline in PXSelect <TaxReportLine, Where <TaxReportLine.vendorID, Equal <Current <VendorMaster.bAccountID> >, And <Where <Current <VendorMaster.showNoTemp>, Equal <boolFalse>, And <TaxReportLine.tempLineNbr, IsNull, Or <Current <VendorMaster.showNoTemp>, Equal <boolTrue>, And <TaxReportLine.tempLineNbr, IsNotNull> > > > > > > .Select(this))
            {
                int linenbr = (int)taxline.LineNbr;
                foreach (var BucketsDict in bucketsArr)
                {
                    if (BucketsDict != null && BucketsDict.ContainsKey(linenbr))
                    {
                        sb.Clear();
                        for (int i = 0; i < BucketsDict[linenbr].Count; i++)
                        {
                            if (i == 0)
                            {
                                sb.Append(BucketsDict[linenbr][i]);
                            }
                            else
                            {
                                sb.AppendFormat("+{0}", BucketsDict[linenbr][i]);
                            }
                        }
                        taxline.BucketSum = sb.ToString();
                    }
                }
                yield return(taxline);
            }
        }
        public static Dictionary <int, List <int> > AnalyseBuckets(PXGraph graph, int BAccountID, string TaxLineType, bool CalcWithZones)
        {
            TaxBucketAnalizer analizer = new TaxBucketAnalizer(graph, BAccountID, TaxLineType);

            return(analizer.AnalyzeBuckets(CalcWithZones));
        }