コード例 #1
0
        protected virtual void KCTaxManagement_StateId_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
        {
            KCTaxManagement row = (KCTaxManagement)e.Row;

            if (row != null && e != null && e.NewValue != null)
            {
                e.NewValue = e.NewValue.ToString().ToUpper();
            }
        }
コード例 #2
0
        protected virtual void KCTaxManagement_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
        {
            var a = KCMarketplaceManagement.Current.MarketplaceId;

            if (e.Row == null)
            {
                return;
            }
            KCTaxManagement row = (KCTaxManagement)e.Row;

            row.MarketplaceId = a;
        }
コード例 #3
0
        protected virtual void KCTaxManagement_UseDefTaxZone_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
        {
            KCTaxManagement row = (KCTaxManagement)e.Row;

            if (row != null && e != null)
            {
                if (e.NewValue != null && (bool)e.NewValue == true)
                {
                    row.TaxZoneId = null;
                    PXUIFieldAttribute.SetEnabled <KCTaxManagement.taxZoneId>(sender, row, false);
                }
            }
        }
コード例 #4
0
        protected virtual void KCTaxManagement_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            KCTaxManagement row = (KCTaxManagement)e.Row;

            if ((row.UseDefTaxZone == null && row.TaxZoneId == null) || (row.UseDefTaxZone == false && row.TaxZoneId == null))
            {
                KCTaxManagement.Cache.RaiseExceptionHandling <KCTaxManagement.useDefTaxZone>(e.Row, row.UseDefTaxZone, new PXSetPropertyException <KCTaxManagement.useDefTaxZone>("Tax Zone option can not be empty"));
                KCTaxManagement.Cache.RaiseExceptionHandling <KCTaxManagement.taxZoneId>(e.Row, row.TaxZoneId, new PXSetPropertyException <KCTaxManagement.taxZoneId>("Tax Zone option can not be empty"));
            }
        }
コード例 #5
0
        protected virtual void KCTaxManagement_RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
        {
            KCTaxManagement row = (KCTaxManagement)e.Row;

            if (row != null)
            {
                if (row.UseDefTaxZone == true)
                {
                    row.TaxZoneId = null;
                    PXUIFieldAttribute.SetEnabled <KCTaxManagement.taxZoneId>(sender, row, false);
                }
                else
                {
                    if (row.TaxZoneId != null)
                    {
                        row.UseDefTaxZone = false;
                        PXUIFieldAttribute.SetEnabled <KCTaxManagement.useDefTaxZone>(sender, row, false);
                    }
                }
            }
        }
コード例 #6
0
        public string GetTaxSettings(KCAPIOrder order, SOOrderEntry orderEntry)
        {
            //string marketplaceName = order.SiteName;
            string marketplaceName = order.BillingFirstName.Split()[0];
            var    orderExt        = orderEntry.GetExtension <KCSOOrderEntryExt>();
            PXResultset <KCTaxManagement> taxManagement = null;
            KCTaxManagement taxrecord     = null;
            int?            marketplaceId = orderExt.KCMarketplaceEntity.SelectSingle(marketplaceName)?.MarketplaceId;

            if (marketplaceId == null)
            {
                marketplaceName = order.SiteName;
                marketplaceId   = orderExt.KCMarketplaceEntity.SelectSingle(marketplaceName)?.MarketplaceId;
            }
            var marketplace      = orderExt.KCMarketplaceManagement.SelectSingle(marketplaceId.ToString());
            var isCATaxZoneExist = orderExt.KCTaxZoneId.SelectSingle(KCConstants.Channel);

            Boolean.TryParse(orderExt.KCXSiteMaster.SelectSingle().IsImportTax, out bool IsImport);
            if (marketplace != null)
            {
                taxManagement = orderExt.KCTaxManagementView.Select(marketplace.MarketplaceId);
                var taxrecordlist = taxManagement.RowCast <KCTaxManagement>().ToList().Where
                                        (x => x.CountryId == order.BillingCountry);
                foreach (var taxman in taxrecordlist)
                {
                    var byState = taxrecordlist.Where(x => (x?.StateId == order.BillingStateOrProvince) || x?.StateId?.Contains(order.BillingStateOrProvince) == true);
                    if (byState.Count() == 0 && taxrecordlist.Where(x => x.CountryId == order.BillingCountry && x?.StateId == null).Count() != 0)
                    {
                        taxrecord = taxrecordlist.Where(x => x.CountryId == order.BillingCountry && x?.StateId == null).FirstOrDefault();
                    }
                    else
                    {
                        taxrecord = byState.FirstOrDefault();
                    }
                }
            }
            if (marketplace != null) // If marketplace exist on Marketplace grid settings
            {
                if (taxManagement != null && taxrecord != null)
                {
                    if (!taxrecord.UseDefTaxZone.GetValueOrDefault()) // if this row has UseDefTaxZone on true
                    {
                        string defTaxZone = taxrecord.TaxZoneId;
                        return(defTaxZone);
                    }
                    else
                    {
                        //if (orderExt.KCXSiteMaster.SelectSingle().IsImportTax == "0") // if UseDefTaxZone is true--use General settings
                        {
                            if (isCATaxZoneExist == null)
                            {
                                SalesTaxMaint stax       = PXGraph.CreateInstance <SalesTaxMaint>();
                                TaxZoneMaint  CAtaxzone  = PXGraph.CreateInstance <TaxZoneMaint>();
                                Tax           tax        = stax.Tax.Insert();
                                TaxZone       newTaxZone = CAtaxzone.TxZone.Insert();
                                TaxZoneDet    taxZoneDet = CAtaxzone.TxZoneDet.Insert();
                                stax.Tax.Cache.SetValue <Tax.taxID>(tax, KCConstants.ChannelAdvisor);
                                stax.Tax.Cache.SetValue <Tax.descr>(tax, KCConstants.ChannelAdvisor);
                                stax.Tax.Cache.SetValue <Tax.salesTaxAcctID>(tax, KCConstants.salesTaxAcctID);
                                stax.Tax.Cache.SetValue <Tax.salesTaxSubID>(tax, KCConstants.salesTaxSubID);
                                stax.Tax.Cache.SetValue <Tax.taxCalcType>(tax, KCConstants.taxCalcType);
                                stax.Tax.Cache.SetValue <Tax.taxCalcLevel>(tax, KCConstants.taxCalcLevel);
                                stax.Persist();
                                CAtaxzone.TxZone.Cache.SetValue <TaxZone.taxZoneID>(newTaxZone, KCConstants.Channel);
                                CAtaxzone.TxZone.Cache.SetValue <TaxZone.descr>(newTaxZone, KCConstants.Channel);
                                CAtaxzone.TxZone.Cache.SetValue <TaxZone.dfltTaxCategoryID>(newTaxZone, KCConstants.Taxable);
                                CAtaxzone.TxZoneDet.Cache.SetValue <TaxZoneDet.taxZoneID>(taxZoneDet, newTaxZone.TaxZoneID);
                                CAtaxzone.TxZoneDet.Cache.SetValue <TaxZoneDet.taxID>(taxZoneDet, tax.TaxID);
                                CAtaxzone.Persist();
                                string defTaxZone = newTaxZone.TaxZoneID;
                                return(defTaxZone);
                            }
                            else
                            {
                                string defTaxZone = isCATaxZoneExist.TaxZoneID;
                                return(defTaxZone);
                            }
                        }
                        //else
                        //{
                        //    string defTaxZone = orderExt.KCXSiteMaster.SelectSingle().TaxZone;
                        //    return defTaxZone;
                        //}
                    }
                }
                else
                {
                    if (!marketplace.UseDefTaxZone.GetValueOrDefault()) // if this row has UseDefTaxZone on true
                    {
                        string defTaxZone = marketplace.TaxZone;
                        return(defTaxZone);
                    }
                    else
                    {
                        //if (orderExt.KCXSiteMaster.SelectSingle().IsImportTax == "0") // if UseDefTaxZone is true--use General settings
                        {
                            if (isCATaxZoneExist == null)
                            {
                                SalesTaxMaint stax       = PXGraph.CreateInstance <SalesTaxMaint>();
                                TaxZoneMaint  CAtaxzone  = PXGraph.CreateInstance <TaxZoneMaint>();
                                Tax           tax        = stax.Tax.Insert();
                                TaxZone       newTaxZone = CAtaxzone.TxZone.Insert();
                                TaxZoneDet    taxZoneDet = CAtaxzone.TxZoneDet.Insert();
                                stax.Tax.Cache.SetValue <Tax.taxID>(tax, KCConstants.ChannelAdvisor);
                                stax.Tax.Cache.SetValue <Tax.descr>(tax, KCConstants.ChannelAdvisor);
                                stax.Tax.Cache.SetValue <Tax.salesTaxAcctID>(tax, KCConstants.salesTaxAcctID);
                                stax.Tax.Cache.SetValue <Tax.salesTaxSubID>(tax, KCConstants.salesTaxSubID);
                                stax.Tax.Cache.SetValue <Tax.taxCalcType>(tax, KCConstants.taxCalcType);
                                stax.Tax.Cache.SetValue <Tax.taxCalcLevel>(tax, KCConstants.taxCalcLevel);
                                stax.Persist();
                                CAtaxzone.TxZone.Cache.SetValue <TaxZone.taxZoneID>(newTaxZone, KCConstants.Channel);
                                CAtaxzone.TxZone.Cache.SetValue <TaxZone.descr>(newTaxZone, KCConstants.Channel);
                                CAtaxzone.TxZone.Cache.SetValue <TaxZone.dfltTaxCategoryID>(newTaxZone, KCConstants.Taxable);
                                CAtaxzone.TxZoneDet.Cache.SetValue <TaxZoneDet.taxZoneID>(taxZoneDet, newTaxZone.TaxZoneID);
                                CAtaxzone.TxZoneDet.Cache.SetValue <TaxZoneDet.taxID>(taxZoneDet, tax.TaxID);
                                CAtaxzone.Persist();
                                string defTaxZone = newTaxZone.TaxZoneID;
                                return(defTaxZone);
                            }
                            else
                            {
                                string defTaxZone = isCATaxZoneExist.TaxZoneID;
                                return(defTaxZone);
                            }
                        }
                        //else
                        //{
                        //    string defTaxZone = orderExt.KCXSiteMaster.SelectSingle().TaxZone;
                        //    return defTaxZone;
                        //}
                    }
                }
            }
            else
            {
                if (orderExt.KCXSiteMaster.SelectSingle().IsImportTax == "0") // if UseDefTaxZone is true--use General settings
                {
                    if (isCATaxZoneExist == null)
                    {
                        SalesTaxMaint stax       = PXGraph.CreateInstance <SalesTaxMaint>();
                        TaxZoneMaint  CAtaxzone  = PXGraph.CreateInstance <TaxZoneMaint>();
                        Tax           tax        = stax.Tax.Insert();
                        TaxZone       newTaxZone = CAtaxzone.TxZone.Insert();
                        TaxZoneDet    taxZoneDet = CAtaxzone.TxZoneDet.Insert();
                        stax.Tax.Cache.SetValue <Tax.taxID>(tax, KCConstants.ChannelAdvisor);
                        stax.Tax.Cache.SetValue <Tax.descr>(tax, KCConstants.ChannelAdvisor);
                        stax.Tax.Cache.SetValue <Tax.salesTaxAcctID>(tax, KCConstants.salesTaxAcctID);
                        stax.Tax.Cache.SetValue <Tax.salesTaxSubID>(tax, KCConstants.salesTaxSubID);
                        stax.Tax.Cache.SetValue <Tax.taxCalcType>(tax, KCConstants.taxCalcType);
                        stax.Tax.Cache.SetValue <Tax.taxCalcLevel>(tax, KCConstants.taxCalcLevel);
                        stax.Persist();
                        CAtaxzone.TxZone.Cache.SetValue <TaxZone.taxZoneID>(newTaxZone, KCConstants.Channel);
                        CAtaxzone.TxZone.Cache.SetValue <TaxZone.descr>(newTaxZone, KCConstants.Channel);
                        CAtaxzone.TxZone.Cache.SetValue <TaxZone.dfltTaxCategoryID>(newTaxZone, KCConstants.Taxable);
                        CAtaxzone.TxZoneDet.Cache.SetValue <TaxZoneDet.taxZoneID>(taxZoneDet, newTaxZone.TaxZoneID);
                        CAtaxzone.TxZoneDet.Cache.SetValue <TaxZoneDet.taxID>(taxZoneDet, tax.TaxID);
                        CAtaxzone.Persist();

                        string defTaxZone = newTaxZone.TaxZoneID;
                        return(defTaxZone);
                    }
                    else
                    {
                        string defTaxZone = isCATaxZoneExist.TaxZoneID;
                        return(defTaxZone);
                    }
                }
                else
                {
                    string defTaxZone = orderExt.KCXSiteMaster.SelectSingle().TaxZone;
                    return(defTaxZone);
                }
            }
        }