Exemple #1
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);
        }
Exemple #2
0
        private static void Translate(TaxImportProcess graph, TXImportState item, TaxBuilder.Result result, out List <Tax> taxes,
                                      out List <KeyValuePair <Tax, List <TaxRev> > > revisions, out List <TaxZone> zones, out List <TaxZoneDet> zoneDetails, out List <TaxCategoryDet> categoryDetails, out List <TaxZoneZip> zoneZips)
        {
            taxes           = new List <Tax>(result.Taxes.Count);
            revisions       = new List <KeyValuePair <Tax, List <TaxRev> > >(result.Taxes.Count);
            zones           = new List <TaxZone>(result.Zones.Count);
            zoneDetails     = new List <TaxZoneDet>(result.ZoneDetails.Count);
            categoryDetails = new List <TaxCategoryDet>(result.Taxes.Count * 2);
            zoneZips        = new List <TaxZoneZip>(result.ZoneZips.Count);

            TXImportSettings settings = PXSetup <TXImportSettings> .Select(graph);

            if (string.IsNullOrEmpty(settings.TaxableCategoryID))
            {
                throw new PXException(Messages.TaxableCategoryIDIsNotSet);
            }

            foreach (ZoneRecord zr in result.Zones)
            {
                TaxZone taxZone = new TaxZone();
                taxZone.TaxZoneID = zr.ZoneID;
                taxZone.Descr     = zr.Description;

                if (zr.CombinedRate > 0)
                {
                    taxZone.DfltTaxCategoryID = settings.TaxableCategoryID;
                }

                taxZone.IsImported = true;
                zones.Add(taxZone);
            }

            foreach (TaxRecord tr in result.Taxes)
            {
                Tax tax = new Tax();
                tax.TaxID          = tr.TaxID;
                tax.TaxType        = CSTaxType.Sales;
                tax.Descr          = tr.Description;
                tax.IsImported     = true;
                tax.SalesTaxAcctID = item.AccountID;
                tax.SalesTaxSubID  = item.SubID;
                tax.TaxCalcType    = CSTaxCalcType.Doc;
                tax.TaxCalcLevel   = CSTaxCalcLevel.CalcOnItemAmt;
                taxes.Add(tax);

                revisions.Add(new KeyValuePair <Tax, List <TaxRev> >(tax, GetRevisions(tr)));
                categoryDetails.AddRange(GetCategories(graph, settings, tr));
            }

            foreach (ZoneDetailRecord zd in result.ZoneDetails)
            {
                TaxZoneDet zoneDetail = new TaxZoneDet();
                zoneDetail.TaxID      = zd.TaxID;
                zoneDetail.TaxZoneID  = zd.ZoneID;
                zoneDetail.IsImported = true;
                zoneDetails.Add(zoneDetail);
            }

            foreach (IList <ZoneZipPlusRecord> zr in result.ZoneZipPlus.Values)
            {
                foreach (ZoneZipPlusRecord zzp in zr)
                {
                    TaxZoneZip tzzp = new TaxZoneZip();
                    tzzp.TaxZoneID = zzp.ZoneID;
                    tzzp.ZipCode   = zzp.ZipCode;
                    tzzp.ZipMin    = zzp.ZipMin;
                    tzzp.ZipMax    = zzp.ZipMax;

                    zoneZips.Add(tzzp);
                }
            }
        }