Example #1
0
 protected virtual void SetFlags(TaxRecord tax, TXImportFileData record)
 {
     tax.IsTaxable = record.CombinedSalesTaxRate > 0;
     tax.IsFreight = record.TaxFreight == "Y";
     tax.IsService = record.TaxServices == "Y";
     tax.IsLabor   = record.TaxServices == "Y" || record.TaxServices == "S";
 }
Example #2
0
        public virtual IEnumerable zoneDetailRecords(string zoneID)
        {
            TaxBuilderFilter filter = Filter.Current;

            if (filter == null)
            {
                yield break;
            }

            if (filter.State == null)
            {
                yield break;
            }

            if (string.IsNullOrEmpty(zoneID))
            {
                yield break;
            }

            bool found = false;

            foreach (ZoneDetailRecord item in ZoneDetailRecords.Cache.Inserted)
            {
                if (item.ZoneID == zoneID)
                {
                    TaxRecord tx = (from t in Taxes
                                    where t.TaxID == item.TaxID
                                    select t).Single();

                    PXResult <ZoneDetailRecord, TaxRecord> res = new PXResult <ZoneDetailRecord, TaxRecord>(item, tx);

                    found = true;
                    yield return(res);
                }
            }
            if (found)
            {
                yield break;
            }

            foreach (ZoneDetailRecord record in ZoneDetails)
            {
                if (record.ZoneID == zoneID)
                {
                    ZoneDetailRecords.Cache.SetStatus(record, PXEntryStatus.Inserted);

                    TaxRecord tx = (from t in Taxes
                                    where t.TaxID == record.TaxID
                                    select t).Single();

                    PXResult <ZoneDetailRecord, TaxRecord> res = new PXResult <ZoneDetailRecord, TaxRecord>(record, tx);


                    yield return(res);
                }
            }
        }
Example #3
0
        protected virtual ZoneDetailRecord AppendZoneDetail(ZoneRecord zone, TaxRecord tax)
        {
            ZoneDetailRecord zd = new ZoneDetailRecord();

            zd.ZoneID = zone.ZoneID;
            zd.TaxID  = tax.TaxID;

            zoneDetails.Add(zd);

            return(zd);
        }
Example #4
0
        protected virtual TaxRecord AppendTax(string taxID, string description)
        {
            TaxRecord tr = new TaxRecord();

            tr.TaxID       = taxID;
            tr.Description = description;


            taxes.Add(tr);

            return(tr);
        }
Example #5
0
        protected virtual TaxRecord AppendTax(string taxID, string description, decimal?rate, DateTime?effectiveDate, decimal?previousRate)
        {
            TaxRecord tr = new TaxRecord();

            tr.TaxID         = taxID;
            tr.Description   = description;
            tr.Rate          = rate;
            tr.EffectiveDate = effectiveDate;
            tr.PreviousRate  = previousRate;

            taxes.Add(tr);

            return(tr);
        }
Example #6
0
        protected override void ExecuteBuilder()
        {
            TaxRecord  stateTax = null;
            TaxRecord  zeroTax  = null;
            ZoneRecord zeroZone = null;
            Dictionary <string, ZoneRecord> zoneDict = new Dictionary <string, ZoneRecord>();

            Dictionary <string, TaxRecord> districtTax        = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> districtTransitTax = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> districtOther1Tax  = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> districtOther2Tax  = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> districtOther3Tax  = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> districtOther4Tax  = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> cityTax            = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> cityTransitTax     = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> cityOther1Tax      = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> cityOther2Tax      = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> cityOther3Tax      = new Dictionary <string, TaxRecord>();
            Dictionary <string, TaxRecord> cityOther4Tax      = new Dictionary <string, TaxRecord>();


            foreach (TXImportFileData t in data)
            {
                string           zoneKey = State;
                List <TaxRecord> list    = new List <TaxRecord>();

                if (!HasTax(t))
                {
                    if (zeroTax == null)
                    {
                        zeroTax = AppendTax(State + "ZERO", "NO Tax", t.CombinedSalesTaxRate, t.CombinedSalesTaxRateEffectiveDate, t.CombinedSalesTaxPreviousRate);
                        SetFlags(zeroTax, t);

                        zeroZone              = new ZoneRecord();
                        zeroZone.ZoneID       = "NO Tax";
                        zeroZone.Description  = "No Tax";
                        zeroZone.CombinedRate = t.CombinedSalesTaxRate;
                        zones.Add(zeroZone);

                        AppendZoneDetail(zeroZone, zeroTax);
                    }

                    AppendZip(zeroZone, t);
                }
                else
                {
                    if (stateTax == null)
                    {
                        stateTax               = AppendTax(State + "STATE", State + " State Tax");
                        stateTax.Rate          = t.StateSalesTaxRate;
                        stateTax.PreviousRate  = t.StateSalesTaxPreviousRate;
                        stateTax.EffectiveDate = t.StateSalesTaxRateEffectiveDate;
                        SetFlags(stateTax, t);
                    }

                    if (t.StateSalesTaxRate > 0)
                    {
                        list.Add(stateTax);
                    }

                    #region County
                    if (t.CountySalesTaxRate > 0 || t.CountySalesTaxPreviousRate > 0)
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeCounty))
                        {
                            zoneKey = t.SignatureCodeCounty;
                        }

                        if (!districtTax.ContainsKey(t.SignatureCodeCounty))
                        {
                            string    taxID = t.StateCode + t.SignatureCodeCounty;
                            TaxRecord info  = AppendTax(taxID, "County Tax " + t.CountyName);
                            info.Rate          = t.CountySalesTaxRate;
                            info.PreviousRate  = t.CountySalesTaxPreviousRate;
                            info.EffectiveDate = t.CountySalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            districtTax.Add(t.SignatureCodeCounty, info);
                            list.Add(info);

                            info.CountyCode = t.SignatureCodeCounty;
                            info.CountyName = t.CountyName;
                        }
                        else
                        {
                            list.Add(districtTax[t.SignatureCodeCounty]);
                        }
                    }

                    if (t.TransitTaxIsCity == "C" && (t.TransitSalesTaxRate > 0 || t.TransitSalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeTransit))
                        {
                            zoneKey = t.SignatureCodeTransit;
                        }

                        if (!districtTransitTax.ContainsKey(t.SignatureCodeTransit))
                        {
                            string    taxID = t.StateCode + "CT" + t.SignatureCodeTransit;
                            TaxRecord info  = AppendTax(taxID, "Transit Tax " + t.CityName);
                            info.Rate          = t.TransitSalesTaxRate;
                            info.PreviousRate  = t.TransitSalesTaxPreviousRate;
                            info.EffectiveDate = t.TransitSalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            districtTransitTax.Add(t.SignatureCodeTransit, info);
                            list.Add(info);

                            info.CountyCode = t.SignatureCodeTransit;
                            info.CountyName = t.CountyName;
                        }
                        else
                        {
                            list.Add(districtTransitTax[t.SignatureCodeTransit]);
                        }
                    }
                    if (t.Other1TaxIsCity == "C" && (t.Other1SalesTaxRate > 0 || t.Other1SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther1))
                        {
                            zoneKey = t.SignatureCodeOther1;
                        }

                        if (!districtOther1Tax.ContainsKey(t.SignatureCodeOther1))
                        {
                            string    taxID = t.StateCode + "CO1" + t.SignatureCodeOther1;
                            TaxRecord info  = AppendTax(taxID, "County Other 1 Tax " + t.CountyName);
                            info.Rate          = t.Other1SalesTaxRate;
                            info.PreviousRate  = t.Other1SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other1SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            districtOther1Tax.Add(t.SignatureCodeOther1, info);
                            list.Add(info);

                            info.CountyCode = t.SignatureCodeOther1;
                            info.CountyName = t.CountyName;
                        }
                        else
                        {
                            list.Add(districtOther1Tax[t.SignatureCodeOther1]);
                        }
                    }
                    if (t.Other2TaxIsCity == "C" && (t.Other2SalesTaxRate > 0 || t.Other2SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther2))
                        {
                            zoneKey = t.SignatureCodeOther2;
                        }

                        if (!districtOther2Tax.ContainsKey(t.SignatureCodeOther2))
                        {
                            string    taxID = t.StateCode + "CO2" + t.SignatureCodeOther2;
                            TaxRecord info  = AppendTax(taxID, "County Other 2 Tax " + t.CountyName);
                            info.Rate          = t.Other2SalesTaxRate;
                            info.PreviousRate  = t.Other2SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other2SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            districtOther2Tax.Add(t.SignatureCodeOther2, info);
                            list.Add(info);

                            info.CountyCode = t.SignatureCodeOther2;
                            info.CountyName = t.CountyName;
                        }
                        else
                        {
                            list.Add(districtOther2Tax[t.SignatureCodeOther2]);
                        }
                    }
                    if (t.Other3TaxIsCity == "C" && (t.Other3SalesTaxRate > 0 || t.Other3SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther3))
                        {
                            zoneKey = t.SignatureCodeOther3;
                        }

                        if (!districtOther3Tax.ContainsKey(t.SignatureCodeOther3))
                        {
                            string    taxID = t.StateCode + "CO3" + t.SignatureCodeOther3;
                            TaxRecord info  = AppendTax(taxID, "County Other 3 Tax " + t.CountyName);
                            info.Rate          = t.Other3SalesTaxRate;
                            info.PreviousRate  = t.Other3SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other3SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            districtOther3Tax.Add(t.SignatureCodeOther3, info);
                            list.Add(info);

                            info.CountyCode = t.SignatureCodeOther3;
                            info.CountyName = t.CountyName;
                        }
                        else
                        {
                            list.Add(districtOther3Tax[t.SignatureCodeOther3]);
                        }
                    }

                    if (t.Other4TaxIsCity == "C" && (t.Other4SalesTaxRate > 0 || t.Other4SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther4))
                        {
                            zoneKey = t.SignatureCodeOther4;
                        }

                        if (!districtOther4Tax.ContainsKey(t.SignatureCodeOther4))
                        {
                            string    taxID = t.StateCode + "CO4" + t.SignatureCodeOther4;
                            TaxRecord info  = AppendTax(taxID, "County Other 4 Tax " + t.CountyName);
                            info.Rate          = t.Other4SalesTaxRate;
                            info.PreviousRate  = t.Other4SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other4SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            districtOther4Tax.Add(t.SignatureCodeOther4, info);
                            list.Add(info);

                            info.CountyCode = t.SignatureCodeOther4;
                            info.CountyName = t.CountyName;
                        }
                        else
                        {
                            list.Add(districtOther4Tax[t.SignatureCodeOther4]);
                        }
                    }
                    #endregion

                    #region City
                    if (t.CitySalesTaxRate > 0 || t.CitySalesTaxPreviousRate > 0)
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeCity))
                        {
                            zoneKey = t.SignatureCodeCity;
                        }

                        if (!cityTax.ContainsKey(t.SignatureCodeCity))
                        {
                            string    taxID = t.StateCode + (t.SignatureCodeCity);
                            TaxRecord info  = AppendTax(taxID, "City Tax " + t.CityName);
                            info.Rate          = t.CitySalesTaxRate;
                            info.PreviousRate  = t.CitySalesTaxPreviousRate;
                            info.EffectiveDate = t.CitySalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            cityTax.Add(t.SignatureCodeCity, info);
                            list.Add(info);

                            info.CityCode = t.SignatureCodeCity;
                            info.CityName = t.CityName;
                        }
                        else
                        {
                            list.Add(cityTax[t.SignatureCodeCity]);
                        }
                    }

                    if (t.TransitTaxIsCity == "T" && (t.TransitSalesTaxRate > 0 || t.TransitSalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeTransit))
                        {
                            zoneKey = t.SignatureCodeTransit;
                        }

                        if (!cityTransitTax.ContainsKey(t.SignatureCodeTransit))
                        {
                            string    taxID = t.StateCode + "TT" + (t.SignatureCodeCounty);
                            TaxRecord info  = AppendTax(taxID, "City Transit Tax " + t.CityName);
                            info.Rate          = t.TransitSalesTaxRate;
                            info.PreviousRate  = t.TransitSalesTaxPreviousRate;
                            info.EffectiveDate = t.TransitSalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            cityTransitTax.Add(t.SignatureCodeTransit, info);
                            list.Add(info);

                            info.CityCode = t.SignatureCodeTransit;
                            info.CityName = t.CityName;
                        }
                        else
                        {
                            list.Add(cityTransitTax[t.SignatureCodeTransit]);
                        }
                    }
                    if (t.Other1TaxIsCity == "T" && (t.Other1SalesTaxRate > 0 || t.Other1SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther1))
                        {
                            zoneKey = t.SignatureCodeOther1;
                        }

                        if (!cityOther1Tax.ContainsKey(t.SignatureCodeOther1))
                        {
                            string    taxID = t.StateCode + "TO1" + (t.SignatureCodeOther1);
                            TaxRecord info  = AppendTax(taxID, "City Other 1 Tax " + t.CityName);
                            info.Rate          = t.Other1SalesTaxRate;
                            info.PreviousRate  = t.Other1SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other1SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            cityOther1Tax.Add(t.SignatureCodeOther1, info);
                            list.Add(info);

                            info.CityCode = t.SignatureCodeOther1;
                            info.CityName = t.CityName;
                        }
                        else
                        {
                            list.Add(cityOther1Tax[t.SignatureCodeOther1]);
                        }
                    }
                    if (t.Other2TaxIsCity == "T" && (t.Other2SalesTaxRate > 0 || t.Other2SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther2))
                        {
                            zoneKey = t.SignatureCodeOther2;
                        }

                        if (!cityOther2Tax.ContainsKey(t.SignatureCodeOther2))
                        {
                            string    taxID = t.StateCode + "TO2" + (t.SignatureCodeOther2);
                            TaxRecord info  = AppendTax(taxID, "City Other 2 Tax " + t.CityName);
                            info.Rate          = t.Other2SalesTaxRate;
                            info.PreviousRate  = t.Other2SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other2SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            cityOther2Tax.Add(t.SignatureCodeOther2, info);
                            list.Add(info);

                            info.CityCode = t.SignatureCodeOther2;
                            info.CityName = t.CityName;
                        }
                        else
                        {
                            list.Add(cityOther2Tax[t.SignatureCodeOther2]);
                        }
                    }
                    if (t.Other3TaxIsCity == "T" && (t.Other3SalesTaxRate > 0 || t.Other3SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther3))
                        {
                            zoneKey = t.SignatureCodeOther3;
                        }

                        if (!cityOther3Tax.ContainsKey(t.SignatureCodeOther3))
                        {
                            string    taxID = t.StateCode + "TO3" + t.SignatureCodeOther3;
                            TaxRecord info  = AppendTax(taxID, "City Other 3 Tax " + t.CityName);
                            info.Rate          = t.Other3SalesTaxRate;
                            info.PreviousRate  = t.Other3SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other3SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            cityOther3Tax.Add(t.SignatureCodeOther3, info);
                            list.Add(info);

                            info.CityCode = t.CityTaxCodeAssignedByState ?? t.OtherTaxCode1AssignedByState;
                            info.CityName = t.CityName;
                        }
                        else
                        {
                            list.Add(cityOther3Tax[t.SignatureCodeOther3]);
                        }
                    }

                    if (t.Other4TaxIsCity == "T" && (t.Other4SalesTaxRate > 0 || t.Other4SalesTaxPreviousRate > 0))
                    {
                        if (!string.IsNullOrEmpty(t.SignatureCodeOther4))
                        {
                            zoneKey = t.SignatureCodeOther4;
                        }

                        if (!cityOther4Tax.ContainsKey(t.SignatureCodeOther4))
                        {
                            string    taxID = t.StateCode + "TO4" + t.SignatureCodeOther4;
                            TaxRecord info  = AppendTax(taxID, "City Other 4 Tax " + t.CityName);
                            info.Rate          = t.Other4SalesTaxRate;
                            info.PreviousRate  = t.Other4SalesTaxPreviousRate;
                            info.EffectiveDate = t.Other4SalesTaxRateEffectiveDate;
                            SetFlags(info, t);
                            cityOther4Tax.Add(t.SignatureCodeOther4, info);
                            list.Add(info);

                            info.CityCode = t.SignatureCodeOther4;
                            info.CityName = t.CityName;
                        }
                        else
                        {
                            list.Add(cityOther4Tax[t.SignatureCodeOther4]);
                        }
                    }
                    #endregion


                    ZoneRecord zr = null;
                    if (!zoneDict.ContainsKey(zoneKey))
                    {
                        string countyZoneID = null;
                        string cityZoneID   = null;
                        string cityName     = null;
                        string countyName   = null;

                        foreach (TaxRecord tr in list)
                        {
                            if (countyZoneID == null && !string.IsNullOrEmpty(tr.CountyCode))
                            {
                                countyZoneID = State + tr.CountyCode;
                                countyName   = tr.CountyName;
                            }
                            else if (countyZoneID != null && !string.IsNullOrEmpty(tr.CountyCode))
                            {
                                if (countyZoneID != (State + tr.CountyCode))
                                {
                                    Debug.Print(string.Format("CountyZoneID mismatch {0} <> {1}", countyZoneID, (State + tr.CountyCode)));
                                }
                            }

                            if (cityZoneID == null && !string.IsNullOrEmpty(tr.CityCode))
                            {
                                cityZoneID = State + tr.CityCode;
                                cityName   = tr.CityName;
                            }
                            else if (cityZoneID != null && !string.IsNullOrEmpty(tr.CityCode))
                            {
                                if (cityZoneID != (State + tr.CityCode))
                                {
                                    Debug.Print(string.Format("CityZoneID mismatch {0} <> {1}", cityZoneID, (State + tr.CityCode)));
                                }
                            }
                        }

                        string zoneID   = cityZoneID;
                        string zoneDesc = countyName;

                        if (zoneID == null)
                        {
                            zoneID = countyZoneID;
                        }

                        if (!string.IsNullOrEmpty(cityName))
                        {
                            zoneDesc = cityName + " - " + countyName;
                        }


                        if (zoneID == null)
                        {
                            zoneID = zoneKey;
                        }

                        if (zoneDesc == null)
                        {
                            zoneDesc = State;
                        }

                        zr              = new ZoneRecord();
                        zr.ZoneID       = zoneID;
                        zr.Description  = zoneDesc;
                        zr.CombinedRate = t.CombinedSalesTaxRate;
                        zones.Add(zr);
                        zoneDict.Add(zoneKey, zr);

                        foreach (TaxRecord tr in list)
                        {
                            AppendZoneDetail(zr, tr);
                        }
                    }
                    else
                    {
                        zr = zoneDict[zoneKey];
                    }


                    AppendZip(zr, t);
                }
            }
        }
Example #7
0
        private static List <TaxRev> GetRevisions(TaxRecord tr)
        {
            List <TaxRev> list = new List <TaxRev>();

            //TODO:
            //split into 2 revisions if rateovermax is specified;
            //split into 2 revisions if previosRate is specified;
            int cx = 1;

            //outdated:
            if (tr.PreviousRate > 0 && tr.EffectiveDate != null)
            {
                TaxRev rev1 = new TaxRev();
                rev1.TaxID       = tr.TaxID;
                rev1.RevisionID  = cx++;
                rev1.IsImported  = true;
                rev1.Outdated    = true;
                rev1.TaxBucketID = SalesTaxBucketID;
                rev1.StartDate   = DateTime.Parse(TaxRev.DefaultStartDate, CultureInfo.InvariantCulture);
                rev1.EndDate     = tr.EffectiveDate ?? DateTime.Parse(TaxRev.DefaultEndDate, CultureInfo.InvariantCulture);
                rev1.TaxType     = CSTaxType.Sales;
                rev1.TaxRate     = tr.Rate * 100;
                list.Add(rev1);
            }

            //current:
            if (tr.TaxableMax != null && tr.TaxableMax > 0)
            {
                //split into 2:
                TaxRev rev1 = new TaxRev();
                rev1.TaxID       = tr.TaxID;
                rev1.RevisionID  = cx++;
                rev1.IsImported  = true;
                rev1.Outdated    = false;
                rev1.TaxBucketID = SalesTaxBucketID;
                rev1.StartDate   = tr.EffectiveDate ?? DateTime.Parse(TaxRev.DefaultStartDate, CultureInfo.InvariantCulture);
                rev1.EndDate     = tr.EffectiveDate ?? DateTime.Parse(TaxRev.DefaultEndDate, CultureInfo.InvariantCulture);
                rev1.TaxType     = CSTaxType.Sales;
                rev1.TaxRate     = tr.Rate * 100;
                rev1.TaxableMax  = tr.TaxableMax;
                list.Add(rev1);

                TaxRev rev2 = new TaxRev();
                rev2.TaxID       = tr.TaxID;
                rev2.RevisionID  = cx++;
                rev2.IsImported  = true;
                rev2.Outdated    = false;
                rev2.TaxBucketID = SalesTaxBucketID;
                rev2.StartDate   = tr.EffectiveDate ?? DateTime.Parse(TaxRev.DefaultStartDate, CultureInfo.InvariantCulture);
                rev2.EndDate     = tr.EffectiveDate ?? DateTime.Parse(TaxRev.DefaultEndDate, CultureInfo.InvariantCulture);
                rev2.TaxType     = CSTaxType.Sales;
                rev2.TaxRate     = tr.RateOverMax * 100;
                rev2.TaxableMin  = tr.TaxableMax;
                list.Add(rev2);
            }
            else
            {
                TaxRev rev1 = new TaxRev();
                rev1.TaxID       = tr.TaxID;
                rev1.RevisionID  = cx++;
                rev1.IsImported  = true;
                rev1.Outdated    = false;
                rev1.TaxBucketID = SalesTaxBucketID;
                rev1.StartDate   = tr.EffectiveDate ?? DateTime.Parse(TaxRev.DefaultStartDate, CultureInfo.InvariantCulture);
                rev1.EndDate     = DateTime.Parse(TaxRev.DefaultEndDate, CultureInfo.InvariantCulture);
                rev1.TaxType     = CSTaxType.Sales;
                rev1.TaxRate     = tr.Rate * 100;
                list.Add(rev1);
            }
            return(list);
        }
Example #8
0
        private static List <TaxCategoryDet> GetCategories(TaxImportProcess graph, TXImportSettings settings, TaxRecord tr)
        {
            List <TaxCategoryDet> list = new List <TaxCategoryDet>();

            TaxCategory taxable = PXSelect <TaxCategory, Where <TaxCategory.taxCategoryID, Equal <Required <TaxCategory.taxCategoryID> > > > .Select(graph, settings.TaxableCategoryID);

            if (taxable != null)
            {
                bool insert = false;

                if (taxable.TaxCatFlag != true)
                {
                    insert = tr.IsTaxable == true;
                }
                else
                {
                    insert = tr.IsTaxable != true;
                }

                if (insert)
                {
                    TaxCategoryDet tcd = new TaxCategoryDet();
                    tcd.TaxID         = tr.TaxID;
                    tcd.TaxCategoryID = settings.TaxableCategoryID;
                    tcd.IsImported    = true;
                    list.Add(tcd);
                }
            }

            TaxCategory freight = PXSelect <TaxCategory, Where <TaxCategory.taxCategoryID, Equal <Required <TaxCategory.taxCategoryID> > > > .Select(graph, settings.FreightCategoryID);

            if (freight != null)
            {
                bool insert = false;

                if (freight.TaxCatFlag != true)
                {
                    insert = tr.IsFreight == true;
                }
                else
                {
                    insert = tr.IsFreight != true;
                }

                if (insert)
                {
                    TaxCategoryDet tcd = new TaxCategoryDet();
                    tcd.TaxID         = tr.TaxID;
                    tcd.TaxCategoryID = settings.FreightCategoryID;
                    tcd.IsImported    = true;
                    list.Add(tcd);
                }
            }

            TaxCategory service = PXSelect <TaxCategory, Where <TaxCategory.taxCategoryID, Equal <Required <TaxCategory.taxCategoryID> > > > .Select(graph, settings.ServiceCategoryID);

            if (service != null)
            {
                bool insert = false;

                if (service.TaxCatFlag != true)
                {
                    insert = tr.IsService == true;
                }
                else
                {
                    insert = tr.IsService != true;
                }

                if (insert)
                {
                    TaxCategoryDet tcd = new TaxCategoryDet();
                    tcd.TaxID         = tr.TaxID;
                    tcd.TaxCategoryID = settings.ServiceCategoryID;
                    tcd.IsImported    = true;
                    list.Add(tcd);
                }
            }

            TaxCategory labor = PXSelect <TaxCategory, Where <TaxCategory.taxCategoryID, Equal <Required <TaxCategory.taxCategoryID> > > > .Select(graph, settings.LaborCategoryID);

            if (labor != null)
            {
                bool insert = false;

                if (labor.TaxCatFlag != true)
                {
                    insert = tr.IsLabor == true;
                }
                else
                {
                    insert = tr.IsLabor != true;
                }

                if (insert)
                {
                    TaxCategoryDet tcd = new TaxCategoryDet();
                    tcd.TaxID         = tr.TaxID;
                    tcd.TaxCategoryID = settings.LaborCategoryID;
                    tcd.IsImported    = true;
                    list.Add(tcd);
                }
            }


            return(list);
        }