protected virtual PXGraph CreateGraph(string graphName, string screenID)
        {
            Type gt = System.Web.Compilation.PXBuildManager.GetType(graphName, false);

            if (gt == null)
            {
                gt = Type.GetType(graphName);
            }
            if (gt != null)
            {
                gt = System.Web.Compilation.PXBuildManager.GetType(PX.Api.CustomizedTypeManager.GetCustomizedTypeFullName(gt), false) ?? gt;
                using (new PXPreserveScope())
                {
                    try
                    {
                        return(gt == typeof(PXGenericInqGrph) ? PXGenericInqGrph.CreateInstance(screenID) : (PXGraph)PXGraph.CreateInstance(gt));
                    }
                    catch (System.Reflection.TargetInvocationException ex)
                    {
                        throw PXException.ExtractInner(ex);
                    }
                }
            }
            return(null);
        }
        protected virtual void Account_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            Account row = (Account)e.Row;

            if (!string.IsNullOrEmpty(row.CuryID))
            {
                CASetup casetup = PXSelect <CASetup> .Select(this);

                if (casetup != null && casetup.TransitAcctId != null && casetup.TransitAcctId == row.AccountID)
                {
                    PXException exception = new PXException(CA.Messages.CashInTransitAccountCanNotBeDenominated);
                    sender.RaiseExceptionHandling <Account.curyID>(row, row.CuryID, exception);
                    throw exception;
                }

                string newCuryid;
                if (e.Operation == PXDBOperation.Update)
                {
                    newCuryid = row.CuryID;
                    byte[] timestamp = PXDatabase.SelectTimeStamp();

                    PXDatabase.Update <GLHistory>(new PXDataFieldAssign("CuryID", newCuryid),
                                                  new PXDataFieldRestrict("AccountID", ((Account)e.Row).AccountID),
                                                  new PXDataFieldRestrict("CuryID", PXDbType.VarChar, 5, null, PXComp.ISNULL),
                                                  new PXDataFieldRestrict("tstamp", PXDbType.Timestamp, 8, timestamp, PXComp.LE));
                }
            }
        }
Esempio n. 3
0
            private static PXGraph CreateGraph(string screenID)
            {
                PXSiteMapNode node = PXSiteMap.Provider.FindSiteMapNodeByScreenID(screenID);

                if (node == null)
                {
                    return(null);
                }
                string graphName = node.GraphType;
                Type   gt        = System.Web.Compilation.PXBuildManager.GetType(graphName, false) ?? Type.GetType(graphName);

                if (gt == null)
                {
                    return(null);
                }

                gt = System.Web.Compilation.PXBuildManager.GetType(PX.Api.CustomizedTypeManager.GetCustomizedTypeFullName(gt), false) ?? gt;
                using (new PXPreserveScope())
                {
                    try
                    {
                        return((PXGraph)PXGraph.CreateInstance(gt));
                    }
                    catch (System.Reflection.TargetInvocationException ex)
                    {
                        throw PXException.ExtractInner(ex);
                    }
                }
            }
Esempio n. 4
0
        public static void TraceAndThrowException(string message, params object[] args)
        {
            var exception = new PXException(message, args);

            PXTrace.WriteError(exception);
            throw exception;
        }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string message          = Request.Params["message"];
        string exceptionID      = Request.Params["exceptionID"];
        string errorcode        = Request.Params["errorcode"];
        string typeID           = Request.Params["typeID"];
        bool   showLogoutButton = (!string.IsNullOrEmpty(Request.Params["showLogoutButton"]) && Request.Params["showLogoutButton"].Trim().ToLower() == "true");

        this.Title = ErrorMessages.GetLocal(ErrorMessages.ErrorHasOccurred);

        ((HyperLink)this.frmBottom.FindControl("lnkTrace")).Text = ErrorMessages.GetLocal(ErrorMessages.ShowTrace);

        if (typeID != null)
        {
            SetUserFriendlyInfoWarning(errorcode, exceptionID);
        }
        else if (exceptionID != null && PXContext.Session.Exception[exceptionID] != null)
        {
            PXException exception = (PXException)PXContext.Session.Exception[exceptionID];
            PXSetupNotEnteredException setPropException = exception as PXSetupNotEnteredException;

            if (setPropException != null)
            {
                string url = GetNextUrl(ref setPropException);
                if (url != null)
                {
                    url = PXPageCache.FixPageUrl(ControlHelper.FixHideScriptUrl(url, null));
                }
                SetUserFriendlyInfo(url, setPropException.NavigateTo, setPropException.ExceptionNumber.ToString(), setPropException.MessageNoPrefix);
            }
            else
            {
                SetDefaultExceptionInfo(exception.ExceptionNumber.ToString(), exception.MessageNoPrefix);
            }
        }
        else if (!String.IsNullOrEmpty(message))
        {
            SetDefaultExceptionInfo(null, message);
        }
        else
        {
            SetDefaultVisibility();
        }

        if (this.User.IsAnonymous())
        {
            ((HyperLink)this.frmBottom.FindControl("lnkTrace")).Visible = false;
        }

        ((Button)this.frmBottom.FindControl("btnLogout")).Visible =
            User != null &&
            User.Identity != null &&
            User.Identity.IsAuthenticated &&
            User.Identity.Name != "anonymous" &&
            showLogoutButton;

        this.Server.ClearError();
    }
        public void ExceptionsLocalization(bool condition)
        {
            PXException e = new PXException("Usernames cannot contain spaces.");

            if (condition)
            {
                throw e;
            }

            throw new PXArgumentException(nameof(ExceptionsLocalization), "Usernames cannot contain commas.");
        }
Esempio n. 7
0
	protected void btnLogin_Click(object sender, EventArgs e)
	{
		try
		{
			string loginText = txtUser.Text;
			if (loginText != null && loginText.Contains(":"))
			{
				this.Master.Message = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.IncorrectLoginSymbols);
				return;
			}
			if (String.IsNullOrEmpty(loginText))
			{
				this.Master.Message = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.InvalidLogin);
				return;
			}

			if (String.IsNullOrEmpty(txtNewPassword.Text) && String.IsNullOrEmpty(txtConfirmPassword.Text))
			{
				string[] companies = null;
				if (PXDatabase.SecureCompanyID && (Membership.Provider is PXBaseMembershipProvider)
					&& String.IsNullOrEmpty(txtVeryDummyPass.Value)
					&& (companies = PXAccess.GetCompanies(loginText, txtPass.Text)).Length > 1)
				{
					SecureLogin(companies);
				}
				else
				{
					NormalLogin(companies);
				}
			}
			else //if user should change it password than we will login different way
			{
				ChangingPassword();
			}
		}
		catch (PXException ex)
		{
			this.Master.Message = ex.MessageNoPrefix;
		}
		catch (System.Reflection.TargetInvocationException ex)
		{
			this.Master.Message = PXException.ExtractInner(ex).Message;
		}
		catch (Exception ex)
		{
			this.Master.Message = ex.Message;
		}
	}
Esempio n. 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string message     = Request.Params["message"];
        string exceptionID = Request.Params["exceptionID"];
        string errorcode   = Request.Params["errorcode"];
        string typeID      = Request.Params["typeID"];

        ((HyperLink)this.frmBottom.FindControl("lnkTrace")).Text = ErrorMessages.GetLocal(ErrorMessages.ShowTrace);

        if (typeID != null)
        {
            SetUserFriendlyInfoWarning(errorcode, System.Web.HttpUtility.HtmlEncode(exceptionID));
        }
        else if (exceptionID != null && PXContext.Session.Exception[exceptionID] != null)
        {
            PXException exception = (PXException)PXContext.Session.Exception[exceptionID];
            PXSetupNotEnteredException setPropException = exception as PXSetupNotEnteredException;

            if (setPropException != null)
            {
                string url = GetNextUrl(ref setPropException);
                if (url != null)
                {
                    url = PXPageCache.FixPageUrl(ControlHelper.FixHideScriptUrl(url, null));
                }
                SetUserFriendlyInfo(url, setPropException.NavigateTo, setPropException.ExceptionNumber.ToString(), setPropException.MessageNoPrefix);
            }
            else
            {
                SetDefaultExceptionInfo(exception.ExceptionNumber.ToString(), exception.MessageNoPrefix);
            }
        }
        else if (!String.IsNullOrEmpty(message))
        {
            SetDefaultExceptionInfo(null, message);
        }
        else
        {
            SetDefaultVisibility();
        }

        if (this.User == null || this.User.Identity == null || !this.User.Identity.IsAuthenticated || this.User.Identity.Name == "anonymous")
        {
            ((HyperLink)this.frmBottom.FindControl("lnkTrace")).Visible = false;
        }

        this.Server.ClearError();
    }
Esempio n. 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string exceptionID = Request.Params["exceptionID"];
        string errorcode   = Request.Params["errorcode"];
        string typeID      = Request.Params["typeID"];

        if (typeID != null)
        {
            SetUserFriendlyInfoWarning(errorcode, exceptionID);
        }
        else
        {
            if (exceptionID != null && PXContext.Session.Exception[exceptionID] != null)
            {
                PXException exception = (PXException)PXContext.Session.Exception[exceptionID];
                PXSetupNotEnteredException setPropException = exception as PXSetupNotEnteredException;

                if (setPropException != null)
                {
                    string url = GetNextUrl(ref setPropException);
                    if (url != null)
                    {
                        url = PXPageCache.FixPageUrl(ControlHelper.FixHideScriptUrl(url, null));
                    }
                    SetUserFriendlyInfo(url, setPropException.NavigateTo, setPropException.ExceptionNumber.ToString(), setPropException.MessageNoPrefix);
                }
                else
                {
                    SetDefaultExceptionInfo(exception.ExceptionNumber.ToString(), exception.MessageNoPrefix);
                }
            }
            else
            {
                SetDefaultVisibility();
            }
        }
        this.Server.ClearError();
    }
Esempio n. 10
0
        protected virtual void _(Events.RowPersisted <ARInvoice> e)
        {
            var ex = new PXException("Something bad happened");

            throw ex;
        }
Esempio n. 11
0
        public void CreateBatch(JournalEntry je, string periodId, int?ledgerID, int?branchID, GLConsolSetup item)
        {
            je.Clear();

            je.glsetup.Current.RequireControlTotal = false;

            Ledger ledger = PXSelect <Ledger,
                                      Where <Ledger.ledgerID, Equal <Required <Ledger.ledgerID> > > >
                            .Select(this, ledgerID);

            FinPeriod fiscalPeriod = PXSelect <FinPeriod,
                                               Where <FinPeriod.finPeriodID, Equal <Required <FinPeriod.finPeriodID> > > > .
                                     Select(this, periodId);

            if (fiscalPeriod == null)
            {
                throw new FiscalPeriodInvalidException(periodId);
            }

            je.Accessinfo.BusinessDate = fiscalPeriod.EndDate.Value.AddDays(-1);

            CurrencyInfo info = new CurrencyInfo();

            info.CuryID      = ledger.BaseCuryID;
            info.CuryEffDate = fiscalPeriod.EndDate.Value.AddDays(-1);
            info.CuryRate    = (decimal)1.0;
            info             = je.currencyinfo.Insert(info);

            Batch batch = new Batch();

            batch.TranPeriodID = periodId;
            batch.BranchID     = branchID;
            batch.LedgerID     = ledgerID;
            batch.Module       = BatchModule.GL;
            batch.Hold         = false;
            batch.Released     = false;
            batch.CuryID       = ledger.BaseCuryID;
            batch.CuryInfoID   = info.CuryInfoID;
            batch.FinPeriodID  = periodId;
            batch.CuryID       = ledger.BaseCuryID;
            batch.BatchType    = BatchTypeCode.Consolidation;
            batch.Description  = PXMessages.LocalizeFormatNoPrefix(Messages.ConsolidationBatch, item.Description);
            batch = je.BatchModule.Insert(batch);

            foreach (GLConsolRead read in listConsolRead)
            {
                Action <decimal?, decimal?> insertTransaction = (debitAmt, creditAmt) =>
                {
                    GLTran tran = new GLTran();

                    tran.AccountID     = read.AccountID;
                    tran.SubID         = read.SubID;
                    tran.CuryInfoID    = info.CuryInfoID;
                    tran.CuryCreditAmt = creditAmt;
                    tran.CuryDebitAmt  = debitAmt;
                    tran.CreditAmt     = creditAmt;
                    tran.DebitAmt      = debitAmt;
                    tran.TranType      = GLTran.tranType.Consolidation;
                    tran.TranClass     = GLTran.tranClass.Consolidation;
                    tran.TranDate      = fiscalPeriod.EndDate.Value.AddDays(-1);
                    tran.TranDesc      = Messages.ConsolidationDetail;
                    tran.TranPeriodID  = periodId;
                    tran.RefNbr        = "";
                    tran.ProjectID     = PM.ProjectDefaultAttribute.NonProject();
                    tran = je.GLTranModuleBatNbr.Insert(tran);

                    if (tran != null && tran.SubID == null && read.MappedValue != null)
                    {
                        je.GLTranModuleBatNbr.SetValueExt <GLTran.subID>(tran, read.MappedValue);
                    }

                    if (tran == null || tran.AccountID == null || tran.SubID == null)
                    {
                        throw new PXException(Messages.AccountOrSubNotFound, read.AccountCD, read.MappedValue);
                    }
                };

                if (Math.Abs((decimal)read.ConsolAmtDebit) > 0)
                {
                    insertTransaction(read.ConsolAmtDebit, 0m);
                }

                if (Math.Abs((decimal)read.ConsolAmtCredit) > 0)
                {
                    insertTransaction(0m, read.ConsolAmtCredit);
                }
            }

            item.LastPostPeriod = periodId;
            item.LastConsDate   = DateTime.Now;
            je.Caches[typeof(GLConsolSetup)].Update(item);
            if (!je.Views.Caches.Contains(typeof(GLConsolSetup)))
            {
                je.Views.Caches.Add(typeof(GLConsolSetup));
            }
            GLConsolBatch cb = new GLConsolBatch();

            cb.SetupID = item.SetupID;
            je.Caches[typeof(GLConsolBatch)].Insert(cb);
            if (!je.Views.Caches.Contains(typeof(GLConsolBatch)))
            {
                je.Views.Caches.Add(typeof(GLConsolBatch));
            }

            try
            {
                je.Save.Press();
            }
            catch (PXException e)
            {
                try
                {
                    if (!String.IsNullOrEmpty(PXUIFieldAttribute.GetError <Batch.curyCreditTotal>(je.BatchModule.Cache, je.BatchModule.Current)) ||
                        !String.IsNullOrEmpty(PXUIFieldAttribute.GetError <Batch.curyDebitTotal>(je.BatchModule.Cache, je.BatchModule.Current)))
                    {
                        je.BatchModule.Current.Hold = true;
                        je.BatchModule.Update(je.BatchModule.Current);
                    }
                    je.Save.Press();
                    if (exception == null)
                    {
                        exception = new PXException(Messages.ConsolidationBatchOutOfBalance, je.BatchModule.Current.BatchNbr);
                    }
                    else
                    {
                        exception = new PXException(exception.Message + Messages.ConsolidationBatchOutOfBalance, je.BatchModule.Current.BatchNbr);
                    }
                }
                catch
                {
                    throw e;
                }
            }
        }
Esempio n. 12
0
        protected virtual int ConsolidationRead(GLConsolSetup item)
        {
            int cnt = 0;

            string aFiscalPeriod = null;
            int?   ledgerID      = item.LedgerId;
            int?   branchID      = item.BranchID;

            var importSubaccountCDCalculator = CreateImportSubaccountMapper(item);

            PXSelect <GLConsolHistory,
                      Where <GLConsolHistory.setupID, Equal <Required <GLConsolHistory.setupID> > > >
            .Select(this, item.SetupID);

            var roundFunc = GetRoundDelegateForLedger(ledgerID);

            JournalEntry je = PXGraph.CreateInstance <JournalEntry>();

            if (item.BypassAccountSubValidation == true)
            {
                je.FieldVerifying.AddHandler <GLTran.accountID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });
                je.FieldVerifying.AddHandler <GLTran.subID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });
            }

            consolSetup = DecryptRemoteUserPassword(item);

            using (PXSoapScope scope = new PXSoapScope(consolSetup.Url, consolSetup.Login, consolSetup.Password))
            {
                GLConsolReadMaint reader = PXGraph.CreateInstance <GLConsolReadMaint>();
                reader.ConsolRecords.Select(item.SourceLedgerCD, item.SourceBranchCD);
                scope.Process(reader);

                int min = 0;
                if (!String.IsNullOrEmpty(item.StartPeriod))
                {
                    int.TryParse(item.StartPeriod, out min);
                }
                int max = 0;
                if (!String.IsNullOrEmpty(item.EndPeriod))
                {
                    int.TryParse(item.EndPeriod, out max);
                }
                foreach (GLConsolData row in reader.ConsolRecords.Select())
                {
                    if (min > 0 || max > 0)
                    {
                        if (!String.IsNullOrEmpty(row.FinPeriodID))
                        {
                            int p;
                            if (int.TryParse(row.FinPeriodID, out p))
                            {
                                if (min > 0 && p < min || max > 0 && p > max)
                                {
                                    continue;
                                }
                            }
                        }
                    }
                    if (aFiscalPeriod == null)
                    {
                        aFiscalPeriod = row.FinPeriodID;
                    }
                    else if (aFiscalPeriod != row.FinPeriodID)
                    {
                        if (listConsolRead.Count > 0)
                        {
                            cnt += AppendRemapped(aFiscalPeriod, ledgerID, branchID, item.SetupID, roundFunc);
                            CreateBatch(je, aFiscalPeriod, ledgerID, branchID, item);
                        }
                        aFiscalPeriod = row.FinPeriodID;
                        listConsolRead.Clear();
                    }

                    GLConsolRead read = new GLConsolRead();

                    var account = AccountMaint.FindAccountByCD(this, row.AccountCD);

                    if (account.AccountID == GLSetup.Current.YtdNetIncAccountID)
                    {
                        throw new PXException(Messages.ImportingYTDNetIncomeAccountDataIsProhibited);
                    }

                    read.AccountCD = account.AccountCD;
                    read.AccountID = account.AccountID;

                    var mappedValue = GetMappedValue(row);
                    var subKeys     = importSubaccountCDCalculator.GetMappedSubaccountKeys(mappedValue);

                    read.MappedValue = subKeys.SubCD;
                    read.SubID       = subKeys.SubID;
                    read.FinPeriodID = row.FinPeriodID;

                    GLConsolHistory history = new GLConsolHistory();
                    history.SetupID     = item.SetupID;
                    history.FinPeriodID = read.FinPeriodID;
                    history.AccountID   = read.AccountID;
                    history.SubID       = read.SubID;
                    history.LedgerID    = item.LedgerId;
                    history.BranchID    = item.BranchID;
                    history             = (GLConsolHistory)Caches[typeof(GLConsolHistory)].Locate(history);

                    if (history != null)
                    {
                        read.ConsolAmtCredit = roundFunc(row.ConsolAmtCredit) - roundFunc(history.PtdCredit);
                        read.ConsolAmtDebit  = roundFunc(row.ConsolAmtDebit) - roundFunc(history.PtdDebit);
                        history.PtdCredit    = 0m;
                        history.PtdDebit     = 0m;
                    }
                    else
                    {
                        read.ConsolAmtCredit = roundFunc(row.ConsolAmtCredit);
                        read.ConsolAmtDebit  = roundFunc(row.ConsolAmtDebit);
                    }

                    if (read.ConsolAmtCredit != 0m || read.ConsolAmtDebit != 0m)
                    {
                        listConsolRead.Add(read);
                        cnt++;
                    }
                }
            }

            if (listConsolRead.Count > 0)
            {
                cnt += AppendRemapped(aFiscalPeriod, ledgerID, branchID, item.SetupID, roundFunc);
                CreateBatch(je, aFiscalPeriod, ledgerID, branchID, item);
            }

            if (exception != null)
            {
                PXException ex = exception;
                exception = null;
                throw ex;
            }

            return(cnt);
        }
Esempio n. 13
0
    /// <summary>
    /// Fill the info about system,
    /// </summary>
    private void SetInfoText()
    {
        string copyR = PXVersionInfo.Copyright;

        txtDummyInstallationID.Value = PXLicenseHelper.InstallationID;

        bool hasError = false;

        if (!PX.Data.Update.PXUpdateHelper.ChectUpdateStatus())
        {
            this.updateError.Style["display"] = "";
            hasError = true;
        }

        if (Request.QueryString["licenseexceeded"] != null)
        {
            this.logOutReasone.Style["display"] = "";
            this.logOutReasoneMsg.InnerText     = PXMessages.LocalizeFormatNoPrefix(
                PX.Data.ActionsMessages.LogoutReason, Request.QueryString["licenseexceeded"]);
            hasError = true;
        }
        else if (Request.QueryString["exceptionID"] != null)
        {
            PXException exception = PXContext.Session.Exception[Request.Params["exceptionID"]] as PXException;
            if (exception != null)
            {
                this.logOutReasone.Style["display"] = "";
                this.logOutReasoneMsg.InnerText     = exception.MessageNoPrefix;
                hasError = true;
            }
        }
        else if (Request.QueryString["message"] != null)
        {
            this.logOutReasone.Style["display"] = "";
            this.logOutReasoneMsg.InnerText     = Request.QueryString["message"];
            hasError = true;
        }
        else if (_passwordRecoveryLinkExpired)
        {
            this.passwordRecoveryError.Style["display"] = "";
            this.passwordRecoveryErrorMsg.InnerText     = PXMessages.LocalizeFormatNoPrefix(ErrorMessages.PasswordRecoveryLinkExpired);
            hasError = true;
        }
        else if (PXDatabase.Companies.Length > PXDatabase.AvailableCompanies.Length)
        {
            this.logOutReasone.Style["display"] = "";
            this.logOutReasoneMsg.InnerText     = PXMessages.LocalizeNoPrefix(PX.Data.ActionsMessages.CompaniesOverlimit);
            hasError = true;
        }

        List <string> dbProblems = new List <string>();

        if (!PXDatabase.Provider.CreateDbServicesPoint().IsDatabaseReadyToWork(ref dbProblems))
        {
            this.dbmsMisconfigured.Style["display"] = "";
            this.dbmsProblems.InnerHtml            += "<UL><li>" + String.Join("</li><li>", dbProblems) + "</li></ul>";
            hasError = true;
        }


        // sets the customization info text
        string status = Customization.CstWebsiteStorage.GetUpgradeStatus();

        if (!String.IsNullOrEmpty(status))
        {
            this.customizationError.Style["display"] = "";
            this.custErrorContent.InnerText          = status;
            hasError = true;
        }
        login_info.Style[HtmlTextWriterStyle.Display] = hasError ? "" : "none";
    }
Esempio n. 14
0
        protected Dictionary <short, string> segmentNames   = new Dictionary <short, string>();     // <segmentid, segmentName>

        protected virtual int ConsolidationRead(GLConsolSetup item)
        {
            int cnt = 0;

            string aFiscalPeriod = null;
            int?   ledgerID      = item.LedgerId;
            int?   branchID      = item.BranchID;
            string segmentValue  = item.SegmentValue;

            InitSegmentData(item);

            PXSelect <GLConsolHistory,
                      Where <GLConsolHistory.setupID, Equal <Required <GLConsolHistory.setupID> > > >
            .Select(this, item.SetupID);

            JournalEntry je = PXGraph.CreateInstance <JournalEntry>();

            if (item.BypassAccountSubValidation == true)
            {
                je.FieldVerifying.AddHandler <GLTran.accountID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });
                je.FieldVerifying.AddHandler <GLTran.subID>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; });
            }

            using (PXSoapScope scope = new PXSoapScope(consolSetup.Url, consolSetup.Login, consolSetup.Password))
            {
                GLConsolReadMaint reader = PXGraph.CreateInstance <GLConsolReadMaint>();
                reader.ConsolRecords.Select(item.SourceLedgerCD, item.SourceBranchCD);
                scope.Process(reader);

                int min = 0;
                if (!String.IsNullOrEmpty(item.StartPeriod))
                {
                    int.TryParse(item.StartPeriod, out min);
                }
                int max = 0;
                if (!String.IsNullOrEmpty(item.EndPeriod))
                {
                    int.TryParse(item.EndPeriod, out max);
                }
                foreach (GLConsolData row in reader.ConsolRecords.Select())
                {
                    if (min > 0 || max > 0)
                    {
                        if (!String.IsNullOrEmpty(row.FinPeriodID))
                        {
                            int p;
                            if (int.TryParse(row.FinPeriodID, out p))
                            {
                                if (min > 0 && p < min || max > 0 && p > max)
                                {
                                    continue;
                                }
                            }
                        }
                    }
                    if (aFiscalPeriod == null)
                    {
                        aFiscalPeriod = row.FinPeriodID;
                    }
                    else if (aFiscalPeriod != row.FinPeriodID)
                    {
                        if (listConsolRead.Count > 0)
                        {
                            cnt += AppendRemapped(aFiscalPeriod, ledgerID, branchID, item.SetupID);
                            CreateBatch(je, aFiscalPeriod, ledgerID, branchID, item);
                        }
                        aFiscalPeriod = row.FinPeriodID;
                        listConsolRead.Clear();
                    }

                    GLConsolRead read      = new GLConsolRead();
                    int?         accountId = ValidateAccountCD(row.AccountCD);
                    string       subCD     = GetRegeneratedSubCD(row.MappedValue);
                    int?         subId     = ValidateSubCD(subCD);

                    read.AccountCD   = row.AccountCD;
                    read.AccountID   = accountId;
                    read.MappedValue = subCD;
                    read.SubID       = subId;
                    read.FinPeriodID = row.FinPeriodID;

                    GLConsolHistory history = new GLConsolHistory();
                    history.SetupID     = item.SetupID;
                    history.FinPeriodID = read.FinPeriodID;
                    history.AccountID   = read.AccountID;
                    history.SubID       = read.SubID;
                    history.LedgerID    = item.LedgerId;
                    history.BranchID    = item.BranchID;
                    history             = (GLConsolHistory)Caches[typeof(GLConsolHistory)].Locate(history);
                    if (history != null)
                    {
                        read.ConsolAmtCredit = (row.ConsolAmtCredit - history.PtdCredit);
                        read.ConsolAmtDebit  = (row.ConsolAmtDebit - history.PtdDebit);
                        history.PtdCredit    = 0m;
                        history.PtdDebit     = 0m;
                    }
                    else
                    {
                        read.ConsolAmtCredit = row.ConsolAmtCredit;
                        read.ConsolAmtDebit  = row.ConsolAmtDebit;
                    }
                    if (read.ConsolAmtCredit != 0m || read.ConsolAmtDebit != 0m)
                    {
                        listConsolRead.Add(read);
                        cnt++;
                    }
                }
            }

            if (listConsolRead.Count > 0)
            {
                cnt += AppendRemapped(aFiscalPeriod, ledgerID, branchID, item.SetupID);
                CreateBatch(je, aFiscalPeriod, ledgerID, branchID, item);
            }

            if (exception != null)
            {
                PXException ex = exception;
                exception = null;
                throw ex;
            }

            return(cnt);
        }