public async Task SaveSettingsDefaults(Guid subscriptionId, bool minimumTaxPayerRegime, bool electronicInvoiceEnabled, bool splitPaymentApplied, Guid?vatId, Guid?providenceFundId, Guid?withholdingTaxId)
        {
            var defaults = _context.SettingsDefaults
                           .BySubscriptionId(subscriptionId)
                           .Include(s => s.Vat)
                           .Include(s => s.WithholdingTax)
                           .Include(s => s.ProvidenceFund)
                           .SingleOrDefault();

            Vat vat = null;

            if (vatId.HasValue)
            {
                vat = _context.Vats.SingleOrDefault(v => v.Id == vatId.Value);
            }

            ProvidenceFund providenceFund = null;

            if (providenceFundId.HasValue)
            {
                providenceFund = _context.ProvidenceFunds.SingleOrDefault(p => p.Id == providenceFundId.Value);
            }

            WithholdingTax withholdingTax = null;

            if (withholdingTaxId.HasValue)
            {
                withholdingTax = _context.WithholdingTaxes.SingleOrDefault(w => w.Id == withholdingTaxId.Value);
            }

            if (defaults == null)
            {
                CreateSettingsDefaults(
                    subscriptionId,
                    minimumTaxPayerRegime,
                    electronicInvoiceEnabled,
                    splitPaymentApplied,
                    vat,
                    providenceFund,
                    withholdingTax);
            }
            else
            {
                EditSettingsDefaults(
                    defaults,
                    minimumTaxPayerRegime,
                    electronicInvoiceEnabled,
                    splitPaymentApplied,
                    vat,
                    providenceFund,
                    withholdingTax);
            }

            await _context.SaveChangesAsync();
        }
Exemple #2
0
        public static WithholdingTax GetWitholdingTax(string pWtCode, string pCompanyDb)
        {
            pCompanyDb.CheckForArgumentNull("pCompanyDb");
            pWtCode.CheckForArgumentNull("pWtCode");

            var wtTax = new WithholdingTax(pCompanyDb)
            {
                WTCode = pWtCode
            };

            if (!wtTax.GetByKey())
            {
                throw new Exception(
                          string.Format(DontFindText1Key, "Imposto Retido na Fonte", pWtCode));
            }

            return(wtTax);
        }
Exemple #3
0
        public List <WithholdingTax> GetWithholdingTax()
        {
            StringBuilder oSQL = new StringBuilder();

            oSQL.Append("SELECT wtCode, wtName FROM OWHT T0 where inactive = 'N'");

            DbCommand dbCommand = this.dataBase.GetSqlStringCommand(oSQL.ToString());

            List <WithholdingTax> withholdingTaxes = new List <WithholdingTax>();

            using (this.reader = this.dataBase.ExecuteReader(dbCommand))
            {
                while (this.reader.Read())
                {
                    WithholdingTax item = new WithholdingTax();
                    item.wtCode = this.reader.IsDBNull(0) ? "" : this.reader.GetValue(0).ToString();
                    item.wtName = this.reader.IsDBNull(1) ? "" : this.reader.GetValue(1).ToString();

                    withholdingTaxes.Add(item);
                }
            }
            return(withholdingTaxes);
        }
        private void EditSettingsDefaults(SettingsDefaults defaults, bool minimumTaxPayerRegime, bool electronicInvoiceEnabled, bool splitPaymentApplied, Vat vat, ProvidenceFund providenceFund, WithholdingTax withholdingTax)
        {
            if (defaults.MinimumTaxPayerRegime != minimumTaxPayerRegime)
            {
                defaults.MinimumTaxPayerRegime = minimumTaxPayerRegime;
            }

            if (defaults.ElectronicInvoiceEnabled != electronicInvoiceEnabled)
            {
                defaults.ElectronicInvoiceEnabled = electronicInvoiceEnabled;
            }

            if (defaults.SplitPaymentApplied != splitPaymentApplied)
            {
                defaults.SplitPaymentApplied = splitPaymentApplied;
            }

            if (defaults.Vat?.Id != vat?.Id)
            {
                defaults.Vat = vat;
            }

            if (defaults.ProvidenceFund?.Id != providenceFund?.Id)
            {
                defaults.ProvidenceFund = providenceFund;
            }

            if (defaults.WithholdingTax?.Id != withholdingTax?.Id)
            {
                defaults.WithholdingTax = withholdingTax;
            }
        }
        private void CreateSettingsDefaults(Guid subscriptionId, bool minimumTaxPayerRegime, bool electronicInvoiceEnabled, bool splitPaymentApplied, Vat vat, ProvidenceFund providenceFund, WithholdingTax withholdingTax)
        {
            var defaults = new SettingsDefaults
            {
                Id                       = Guid.NewGuid(),
                SubscriptionId           = subscriptionId,
                ElectronicInvoiceEnabled = electronicInvoiceEnabled,
                MinimumTaxPayerRegime    = minimumTaxPayerRegime,
                SplitPaymentApplied      = splitPaymentApplied,
                ProvidenceFund           = providenceFund,
                Vat                      = vat,
                WithholdingTax           = withholdingTax
            };

            _context.Add(defaults);
        }
Exemple #6
0
        public static void MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            try
            {
                #region Autoretention

                if (pVal.MenuUID == "BYB_MWT04" &&
                    !pVal.BeforeAction)
                {
                    SelfWithholdingTax.loadCancelSWTaxForm();
                }
                if (pVal.MenuUID == "BYB_MWT03" &&
                    !pVal.BeforeAction)
                {
                    SelfWithholdingTax.loadMissingSWTaxForm();
                }

                //COnfiguración Autoretencion
                if (pVal.MenuUID == "BYB_MWT02" &&
                    !pVal.BeforeAction)
                {
                    SelfWithholdingTax.loadSWTaxConfigForm();
                }

                //Add Row BP
                if (pVal.MenuUID == "BYB_MWTRU" &&
                    !pVal.BeforeAction)
                {
                    EventInfoClass eventInfo = CacheManager.CacheManager.Instance.getFromCache(Settings._Main.lastRightClickEventInfo);
                    SelfWithholdingTax.relatedPartiedMatrixOperationUDO(eventInfo, "Add");
                }
                //Remove Row BP
                if (pVal.MenuUID == "BYB_MWTDRU" &&
                    !pVal.BeforeAction)
                {
                    EventInfoClass eventInfo = CacheManager.CacheManager.Instance.getFromCache(Settings._Main.lastRightClickEventInfo);
                    SelfWithholdingTax.relatedPartiedMatrixOperationUDO(eventInfo, "Delete");
                }
                #endregion

                #region Retenciones
                if (pVal.MenuUID == "5897" &&
                    pVal.BeforeAction)
                {
                    string strLastActiveForm = MainObject.Instance.B1Application.Forms.ActiveForm.UniqueID;
                    CacheManager.CacheManager.Instance.addToCache("WTLastActiveForm", strLastActiveForm, CacheManager.CacheManager.objCachePriority.Default);
                }
                if (pVal.MenuUID == "6005" &&
                    pVal.BeforeAction)
                {
                    string strLastActiveForm = MainObject.Instance.B1Application.Forms.ActiveForm.UniqueID;
                    CacheManager.CacheManager.Instance.addToCache("LastActiveForm", strLastActiveForm, CacheManager.CacheManager.objCachePriority.Default);
                }

                if (pVal.MenuUID == "BYB_MWT06" &&
                    pVal.BeforeAction)
                {
                    MainObject.Instance.B1Application.OpenForm(SAPbouiCOM.BoFormObjectEnum.fo_UserDefinedObject, "BYB_T1WHT200", "");
                }

                //Transacciones faltantes
                if (pVal.MenuUID == "BYB_MWT07" &&
                    !pVal.BeforeAction)
                {
                    WithholdingTax.loadMissingOperationsForm();
                }



                #endregion
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }
Exemple #7
0
        public static void formDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool blBubbleEvent)
        {
            if (objWithHoldingTax == null)
            {
                objWithHoldingTax = new Operations();
            }

            blBubbleEvent = true;
            try
            {
                #region Autoretenciones
                #region Invoice
                if (BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.FormTypeEx == "133" &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
                {
                    SelfWithholdingTax.addSelfWithHoldingTax(BusinessObjectInfo);
                }

                if (BusinessObjectInfo.ActionSuccess &&
                    (BusinessObjectInfo.FormTypeEx == "133" || BusinessObjectInfo.FormTypeEx == "179") &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD)
                {
                    SelfWithholdingTax.getSWTaxInfoForDocument(BusinessObjectInfo);
                }
                #endregion

                #region CreditNote
                if (BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.FormTypeEx == "179" &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
                {
                    SelfWithholdingTax.addSelfWithHoldingTax(BusinessObjectInfo);
                }
                #endregion


                #endregion

                #region Retenciones

                if (BusinessObjectInfo.ActionSuccess &&
                    (WHPurchaseDocuments.Contains(BusinessObjectInfo.FormTypeEx) || WHSalesDocuments.Contains(BusinessObjectInfo.FormTypeEx)) &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
                {
                    AddDocumentInfoArgs objArgs = new AddDocumentInfoArgs();
                    objArgs.ObjectKey   = BusinessObjectInfo.ObjectKey;
                    objArgs.ObjectType  = BusinessObjectInfo.Type;
                    objArgs.FormtTypeEx = BusinessObjectInfo.FormTypeEx;
                    objArgs.FormUID     = BusinessObjectInfo.FormUID;

                    WithholdingTax.addDocumentInfo(objArgs);
                }

                #endregion
            }
            catch (COMException COMException)
            {
                _Logger.Error("", COMException);
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }
Exemple #8
0
        public static void ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
        {
            if (objWithHoldingTax == null)
            {
                objWithHoldingTax = new Operations();
            }
            string[] showInFolderList;
            bool     blInList = false;

            BubbleEvent = true;
            try
            {
                #region WithHolding Tax

                #region Purchase


                if (WHPurchaseDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    (pVal.ItemUID == "4" || pVal.ItemUID == "54") &&
                    !pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        WithholdingTax.getSelectedBPInformation(pVal, true);
                        CacheManager.CacheManager.Instance.addToCache("WTCFLExecuted", true, CacheManager.CacheManager.objCachePriority.Default);
                    }
                }

                if (WHPurchaseDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD &&
                    !pVal.BeforeAction

                    )
                {
                    CacheManager.CacheManager.Instance.removeFromCache("Disable_" + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache(Settings._WithHoldingTax.WTInfoGenCachePrefix + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache(Settings._WithHoldingTax.WTFOrmInfoCachePrefix + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache(Settings._WithHoldingTax.WTLastCardCodeCachePrefix + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache("WTLogicDone_" + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache("WTCFLExecuted");
                    CacheManager.CacheManager.Instance.removeFromCache("WTLastActiveForm");
                }

                if (WHPurchaseDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_LOST_FOCUS &&
                    !pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        bool WTExec    = CacheManager.CacheManager.Instance.getFromCache("WTCFLExecuted") == null ? false : true;
                        bool LogicDone = CacheManager.CacheManager.Instance.getFromCache("WTLogicDone_" + pVal.FormUID) == null ? false : true;
                        if (pVal.ItemUID == "4" || pVal.ItemUID == "54")
                        {
                            LogicDone = false;
                        }

                        if (!LogicDone)
                        {
                            if (!WTExec)
                            {
                                WithholdingTax.getSelectedBPInformation(pVal, false);
                            }
                            else
                            {
                                CacheManager.CacheManager.Instance.removeFromCache("WTCFLExecuted");
                            }

                            WithholdingTax.activateWTMenu(pVal.FormUID);
                        }
                    }
                }
                // BillTo Combobox
                if (WHPurchaseDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT &&
                    pVal.ItemUID == "226" &&
                    !pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        WithholdingTax.getSelectedBPInformation(pVal, false);
                        WithholdingTax.activateWTMenu(pVal.FormUID);
                    }
                }

                //LinkTo WT Table arrow
                if (WHPurchaseDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    pVal.ItemUID == "173" &&
                    pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        string strLastActiveForm = MainObject.Instance.B1Application.Forms.ActiveForm.UniqueID;
                        CacheManager.CacheManager.Instance.addToCache("WTLastActiveForm", strLastActiveForm, CacheManager.CacheManager.objCachePriority.Default);
                    }
                }



                #endregion

                #region Sales


                if (WHSalesDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    (pVal.ItemUID == "4" || pVal.ItemUID == "54") &&
                    !pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        WithholdingTax.getSelectedBPInformation(pVal, true);
                        CacheManager.CacheManager.Instance.addToCache("WTCFLExecuted", true, CacheManager.CacheManager.objCachePriority.Default);
                    }
                }

                if (WHSalesDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD &&
                    !pVal.BeforeAction

                    )
                {
                    CacheManager.CacheManager.Instance.removeFromCache("Disable_" + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache(Settings._WithHoldingTax.WTInfoGenCachePrefix + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache(Settings._WithHoldingTax.WTFOrmInfoCachePrefix + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache(Settings._WithHoldingTax.WTLastCardCodeCachePrefix + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache("WTLogicDone_" + pVal.FormUID);
                    CacheManager.CacheManager.Instance.removeFromCache("WTCFLExecuted");
                    CacheManager.CacheManager.Instance.removeFromCache("WTLastActiveForm");
                }

                if (WHSalesDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_LOST_FOCUS &&
                    !pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        bool WTExec    = CacheManager.CacheManager.Instance.getFromCache("WTCFLExecuted") == null ? false : true;
                        bool LogicDone = CacheManager.CacheManager.Instance.getFromCache("WTLogicDone_" + pVal.FormUID) == null ? false : true;
                        if (pVal.ItemUID == "4" || pVal.ItemUID == "54")
                        {
                            LogicDone = false;
                        }

                        if (!LogicDone)
                        {
                            if (!WTExec)
                            {
                                WithholdingTax.getSelectedBPInformation(pVal, false);
                            }
                            else
                            {
                                CacheManager.CacheManager.Instance.removeFromCache("WTCFLExecuted");
                            }

                            WithholdingTax.activateWTMenu(pVal.FormUID);
                        }
                    }
                }
                // BillTo Combobox
                if (WHSalesDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT &&
                    pVal.ItemUID == "226" &&
                    !pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        WithholdingTax.getSelectedBPInformation(pVal, false);
                        WithholdingTax.activateWTMenu(pVal.FormUID);
                    }
                }

                //LinkTo WT Table arrow
                if (WHSalesDocuments.Contains(pVal.FormTypeEx) &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    pVal.ItemUID == "173" &&
                    pVal.BeforeAction

                    )
                {
                    if (WithholdingTax.formModeAdd(pVal))
                    {
                        string strLastActiveForm = MainObject.Instance.B1Application.Forms.ActiveForm.UniqueID;
                        CacheManager.CacheManager.Instance.addToCache("WTLastActiveForm", strLastActiveForm, CacheManager.CacheManager.objCachePriority.Default);
                    }
                }



                #endregion

                #region Missing Operations
                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    !pVal.BeforeAction &&
                    pVal.ActionSuccess &&
                    pVal.FormTypeEx == "BYB_FMWT01" &&
                    pVal.ItemUID == "btnAdd"
                    )
                {
                    WithholdingTax.createMissingOperations(pVal);
                }
                #endregion

                //if (pVal.FormTypeEx == "133"
                //    && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
                //    && pVal.ItemUID == "10002122"
                //    && !pVal.BeforeAction)
                //{
                //    bool isDisabled = CacheManager.CacheManager.Instance.getFromCache("Disable_" + pVal.FormUID) == null ? false : true;
                //    if (!isDisabled)
                //    {
                //        WithholdingTax.getWTforBP(pVal,false);
                //    }
                //}

                #region WithHolding Tax Form

                if (pVal.FormTypeEx == "60504" &&
                    !pVal.BeforeAction &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD)
                {
                    string strLastActiveForm = CacheManager.CacheManager.Instance.getFromCache("WTLastActiveForm") == null ? "" : CacheManager.CacheManager.Instance.getFromCache("WTLastActiveForm");
                    if (strLastActiveForm.Trim().Length > 0)
                    {
                        bool blDisabled = CacheManager.CacheManager.Instance.getFromCache("Disable_" + strLastActiveForm) != null ? true : false;
                        if (!blDisabled)
                        {
                            string strFormAutoActivate = CacheManager.CacheManager.Instance.getFromCache("WTAutoActivate") != null?CacheManager.CacheManager.Instance.getFromCache("WTAutoActivate") : "";

                            if (strFormAutoActivate.Trim() == strLastActiveForm.Trim())
                            {
                                T1.B1.Base.UIOperations.Operations.startProgressBar("Asignando retenciones automáticas...", 2);
                                WithholdingTax.setBPWT(strFormAutoActivate, pVal);
                                //CacheManager.CacheManager.Instance.removeFromCache("WTLastActiveForm");
                                //T1.B1.Base.UIOperations.Operations.stopProgressBar();
                            }
                        }
                    }
                }
                if (pVal.FormTypeEx == "60504" &&
                    pVal.BeforeAction &&
                    pVal.EventType != SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    pVal.ItemUID == "1")
                {
                    string blAutoActivate = CacheManager.CacheManager.Instance.getFromCache("WTAutoActivate") != null?CacheManager.CacheManager.Instance.getFromCache("WTAutoActivate") : "";

                    SAPbouiCOM.Form objForm           = null;
                    string          strLastActiveForm = CacheManager.CacheManager.Instance.getFromCache("WTLastActiveForm") == null ? "" : CacheManager.CacheManager.Instance.getFromCache("WTLastActiveForm");
                    if (strLastActiveForm.Trim().Length > 0)
                    {
                        bool isDisabled = CacheManager.CacheManager.Instance.getFromCache("Disable_" + strLastActiveForm) == null ? false : true;
                        if (blAutoActivate.Trim().Length == 0)
                        {
                            objForm = MainObject.Instance.B1Application.Forms.Item(pVal.FormUID);
                            if (objForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE && !isDisabled)
                            {
                                if (MainObject.Instance.B1Application.MessageBox("La modificación manual de las retenciones deshabilitará el cálculo automatico para este documento. Desea Continuar? ", 2, "Sí", "No", "") != 2)
                                {
                                    if (strLastActiveForm.Trim().Length > 0)
                                    {
                                        CacheManager.CacheManager.Instance.addToCache(string.Concat("Disable_", strLastActiveForm), true, CacheManager.CacheManager.objCachePriority.Default);
                                    }
                                    else
                                    {
                                        if (objForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE)
                                        {
                                            objForm.Items.Item("1").Click(SAPbouiCOM.BoCellClickType.ct_Regular);
                                        }
                                        else
                                        {
                                            BubbleEvent = false;
                                        }
                                    }

                                    objForm.Close();
                                }
                                else
                                {
                                    BubbleEvent = false;
                                    objForm.Items.Item("2").Click(SAPbouiCOM.BoCellClickType.ct_Regular);
                                }
                            }
                            CacheManager.CacheManager.Instance.removeFromCache("WTLastActiveForm");
                            T1.B1.Base.UIOperations.Operations.stopProgressBar();
                        }
                    }
                }



                #endregion

                #region Autoretenciones

                #region Cancel Wizard
                if (pVal.FormTypeEx == Settings._SelfWithHoldingTax.CancelFormUID &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    !pVal.BeforeAction &&
                    pVal.ItemUID == "btnGet"
                    )
                {
                    SelfWithholdingTax.getPostedSWTaxDocuments(FormUID, pVal);
                }


                if (pVal.FormTypeEx == Settings._SelfWithHoldingTax.CancelFormUID &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    !pVal.BeforeAction &&
                    pVal.ItemUID == "txtSWTCode"
                    )
                {
                    SelfWithholdingTax.setSelectedCode(pVal);
                }

                if (!pVal.BeforeAction &&
                    pVal.EventType != SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_DOUBLE_CLICK &&
                    pVal.ItemUID == "grdSWT" &&
                    pVal.FormTypeEx == Settings._SelfWithHoldingTax.CancelFormUID)
                {
                    T1.B1.Base.UIOperations.Operations.toggleSelectCheckBox(pVal, "dtSelfWT", "1");
                }

                if (!pVal.BeforeAction &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED

                    && pVal.ItemUID == "btnCalc" &&
                    pVal.FormTypeEx == Settings._SelfWithHoldingTax.CancelFormUID)
                {
                    SelfWithholdingTax.cancelPostedTaxDocuments(FormUID, pVal);
                }
                #endregion

                #region SelfWithholdingTax Config Form

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "13_U_E")
                {
                    SelfWithholdingTax.filterAccounts(pVal, "CFL_DB");
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    !pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "13_U_E")
                {
                    SelfWithholdingTax.clearfilterAccounts(pVal, "CFL_DB");
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "14_U_E")
                {
                    SelfWithholdingTax.filterAccounts(pVal, "CFL_CR");
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    !pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "14_U_E")
                {
                    SelfWithholdingTax.clearfilterAccounts(pVal, "CFL_CR");
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    !pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "0_U_G")
                {
                    SelfWithholdingTax.setBPNameColumn(pVal);
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "0_U_G")
                {
                    SelfWithholdingTax.filterBPs(pVal);
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST &&
                    !pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "0_U_G")
                {
                    SelfWithholdingTax.clearfilterBPs(pVal);
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    !pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "btnAddAll")
                {
                    SelfWithholdingTax.addAllPBS(pVal);
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    !pVal.BeforeAction &&
                    pVal.FormTypeEx == "BYB_T1SWT100UDO" &&
                    pVal.ItemUID == "btnClear")
                {
                    SelfWithholdingTax.clearAllPBS(pVal);
                }

                #endregion

                #region SelfWithholdingTax Folder in Documents



                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD &&
                    !pVal.BeforeAction &&
                    pVal.ActionSuccess

                    )
                {
                    showInFolderList = Settings._SelfWithHoldingTax.showFolderInDocumentsList.Split(',');
                    for (int i = 0; i < showInFolderList.Length; i++)
                    {
                        if (showInFolderList[i] == pVal.FormTypeEx)
                        {
                            blInList = true;
                            break;
                        }
                    }
                    if (blInList)
                    {
                        SelfWithholdingTax.BYBSelfWithHoldingFolderAdd(pVal.FormUID);
                        runResizelogic = false;
                    }
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_RESIZE &&
                    !pVal.BeforeAction

                    )
                {
                    if (runResizelogic)
                    {
                        showInFolderList = Settings._SelfWithHoldingTax.showFolderInDocumentsList.Split(',');
                        for (int i = 0; i < showInFolderList.Length; i++)
                        {
                            if (showInFolderList[i] == pVal.FormTypeEx)
                            {
                                blInList = true;
                                break;
                            }
                        }
                        if (blInList)
                        {
                            SelfWithholdingTax.BYBSelfWithHoldingFolderAdd(pVal.FormUID);
                            blInList = false;
                        }
                    }
                    runResizelogic = true;
                }

                if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    !pVal.BeforeAction &&
                    pVal.ItemUID == Settings._SelfWithHoldingTax.SelfWithHoldingFolderId
                    )
                {
                    showInFolderList = Settings._SelfWithHoldingTax.showFolderInDocumentsList.Split(',');
                    for (int i = 0; i < showInFolderList.Length; i++)
                    {
                        if (showInFolderList[i] == pVal.FormTypeEx)
                        {
                            blInList = true;
                            break;
                        }
                    }
                    if (blInList)
                    {
                        MainObject.Instance.B1Application.Forms.Item(pVal.FormUID).PaneLevel = Settings._SelfWithHoldingTax.SelfWithHoldingFolderPane;
                    }
                }
                #endregion


                #region AddWizard
                if (pVal.FormTypeEx == Settings._SelfWithHoldingTax.MissingSWTFormUID &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    !pVal.BeforeAction &&
                    pVal.ItemUID == "btnGet"
                    )
                {
                    SelfWithholdingTax.getMissingSWTaxDocuments(FormUID, pVal);
                }



                if (!pVal.BeforeAction &&
                    pVal.EventType != SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_DOUBLE_CLICK &&
                    pVal.ItemUID == "grdSWT" &&
                    pVal.FormTypeEx == Settings._SelfWithHoldingTax.MissingSWTFormUID)
                {
                    T1.B1.Base.UIOperations.Operations.toggleSelectCheckBox(pVal, "dtSelfWT", "1");
                }

                if (!pVal.BeforeAction &&
                    pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED

                    && pVal.ItemUID == "btnCalc" &&
                    pVal.FormTypeEx == Settings._SelfWithHoldingTax.MissingSWTFormUID)
                {
                    SelfWithholdingTax.addMisingSWTDocuments(FormUID, pVal);
                }

                #endregion
                #endregion
                #endregion
            }
            catch (COMException comEx)
            {
                _Logger.Error("", comEx);
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
            finally
            {
                T1.B1.Base.UIOperations.Operations.stopProgressBar();
            }
        }