Ejemplo n.º 1
0
        protected virtual void TaxCategoryDet_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            TaxCategoryDet row = e.Row as TaxCategoryDet;

            if (row != null)
            {
                PXUIFieldAttribute.SetEnabled <TaxCategoryDet.taxID>(sender, row, string.IsNullOrEmpty(row.TaxID));
            }
        }
Ejemplo n.º 2
0
        protected virtual void TaxCategoryDet_TaxID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
        {
            TaxCategoryDet tax   = (TaxCategoryDet)e.Row;
            string         taxId = (string)e.NewValue;

            if (tax.TaxID != taxId)
            {
                foreach (TaxCategoryDet iTax in this.Details.Select())
                {
                    if (iTax.TaxID == taxId)
                    {
                        e.Cancel = true;
                        throw new PXSetPropertyException(Messages.TaxAlreadyInList);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void Process(TaxImportProcess graph, TXImportState item)
        {
            TaxBuilder.Result result = TaxBuilderEngine.Execute(graph, item.StateCode);

            List <Tax> taxes;
            List <KeyValuePair <Tax, List <TaxRev> > > revisions;
            List <TaxZone>        zones;
            List <TaxZoneDet>     zoneDetails;
            List <TaxCategoryDet> categoryDetails;
            List <TaxZoneZip>     zoneZips;

            Translate(graph, item, result, out taxes, out revisions, out zones, out zoneDetails, out categoryDetails, out zoneZips);

            //Save to TX module:

            foreach (TaxZone zone in zones)
            {
                TaxZone existing = PXSelect <TaxZone, Where <TaxZone.taxZoneID, Equal <Required <TaxZone.taxZoneID> > > > .Select(graph, zone.TaxZoneID);

                if (existing == null)
                {
                    graph.TaxZones.Insert(zone);
                }

                PXSelectBase <TaxZoneZip> selectZips = new PXSelect <TaxZoneZip, Where <TaxZoneZip.taxZoneID, Equal <Required <TaxZoneZip.taxZoneID> > > >(graph);
                foreach (TaxZoneZip z in selectZips.Select(zone.TaxZoneID))
                {
                    graph.TaxZoneZip.Delete(z);
                }
            }

            foreach (TaxZoneZip zip in zoneZips)
            {
                graph.TaxZoneZip.Insert(zip);
            }

            foreach (Tax tax in taxes)
            {
                Tax existing = PXSelect <Tax, Where <Tax.taxID, Equal <Required <Tax.taxID> > > > .Select(graph, tax.TaxID);

                if (existing == null)
                {
                    graph.Taxes.Insert(tax);
                }
            }

            foreach (KeyValuePair <Tax, List <TaxRev> > kv in revisions)
            {
                PXResultset <TaxRev> existingRevisions = PXSelect <TaxRev, Where <TaxRev.taxID, Equal <Required <TaxRev.taxID> > > > .Select(graph, kv.Key.TaxID);


                if (existingRevisions.Count == 0)
                {
                    foreach (TaxRev revision in kv.Value)
                    {
                        graph.Revisions.Insert(revision);
                    }
                }
                else
                {
                    foreach (TaxRev revision in kv.Value)
                    {
                        bool skip = false;
                        foreach (TaxRev existing in existingRevisions)
                        {
                            if (graph.Revisions.Cache.ObjectsEqual <TaxRev.startDate, TaxRev.endDate, TaxRev.taxRate>(revision, existing))
                            {
                                skip = true;
                                break;
                            }
                        }

                        if (!skip)
                        {
                            graph.Revisions.Insert(revision);
                        }
                    }
                }
            }

            foreach (TaxCategoryDet category in categoryDetails)
            {
                TaxCategoryDet existing = PXSelect <TaxCategoryDet, Where <TaxCategoryDet.taxID, Equal <Required <TaxCategoryDet.taxID> >,
                                                                           And <TaxCategoryDet.taxCategoryID, Equal <Required <TaxCategoryDet.taxCategoryID> > > > > .Select(graph, category.TaxID, category.TaxCategoryID);

                if (existing == null)
                {
                    graph.TaxCategoryDetails.Insert(category);
                }
            }

            foreach (TaxZoneDet zd in zoneDetails)
            {
                TaxZoneDet existing = PXSelect <TaxZoneDet, Where <TaxZoneDet.taxID, Equal <Required <TaxZoneDet.taxID> >,
                                                                   And <TaxZoneDet.taxZoneID, Equal <Required <TaxZoneDet.taxZoneID> > > > > .Select(graph, zd.TaxID, zd.TaxZoneID);

                if (existing == null)
                {
                    graph.TaxZoneDetails.Insert(zd);
                }
            }

            graph.Actions.PressSave();
        }
Ejemplo n.º 4
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);
        }