コード例 #1
0
        protected virtual void TaxTran_RevisionID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            if (Document.Current.BranchID == null)
            {
                e.NewValue = null;
            }
            else
            {
                Organization organization = OrganizationMaint.FindOrganizationByID(this, PXAccess.GetParentOrganizationID(Document.Current.BranchID));
                int?[]       branchID     = organization.FileTaxesByBranches == true ? new[] { Document.Current.BranchID } : null;

                using (new PXReadBranchRestrictedScope(organization.OrganizationID.SingleToArray(), branchID, requireAccessForAllSpecified: true))
                {
                    TaxHistory max =
                        PXSelect <TaxHistory,
                                  Where <TaxHistory.vendorID, Equal <Current <TaxAdjustment.vendorID> >,
                                         And <TaxHistory.taxPeriodID, Equal <Current <TaxAdjustment.taxPeriod> > > >,
                                  OrderBy <
                                      Desc <TaxHistory.revisionID> > >
                        .Select(this);

                    e.NewValue = max != null ? max.RevisionID : 1;
                }
            }
        }
コード例 #2
0
        protected void baseVATPeriodFilterRowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            VATPeriodFilter filter = e.Row as VATPeriodFilter;

            if (filter?.OrganizationID == null)
            {
                return;
            }

            Organization organization = OrganizationMaint.FindOrganizationByID(this, filter.OrganizationID);

            if (organization.FileTaxesByBranches == true && filter.BranchID == null ||
                filter.VendorID == null || filter.TaxPeriodID == null)
            {
                return;
            }

            TaxPeriod taxPeriod = Period.Select();

            int?maxRevision = ReportTaxProcess.CurrentRevisionId(sender.Graph, filter.OrganizationID, filter.BranchID, filter.VendorID, filter.TaxPeriodID);

            filter.StartDate = taxPeriod?.StartDateUI;
            filter.EndDate   = taxPeriod?.EndDate != null     ? (DateTime?)(((DateTime)taxPeriod.EndDate).AddDays(-1)) : null;

            PXUIFieldAttribute.SetEnabled <VATPeriodFilter.revisionId>(sender, null, maxRevision > 1);
            PXUIFieldAttribute.SetEnabled <VATPeriodFilter.taxPeriodID>(sender, null, true);
        }
コード例 #3
0
        public virtual IEnumerable Year1099DetailReport(PXAdapter adapter)
        {
            if (Year_Header.Current != null)
            {
                Organization org = OrganizationMaint.FindOrganizationByID(this, Year_Header.Current.OrganizationID);

                if (org?.Reporting1099ByBranches == true)
                {
                    throw new PXException(Messages.CannotShowReportForEntireOrganization);
                }

                BAccountR orgBAccount =
                    SelectFrom <BAccountR>
                    .Where <BAccountR.bAccountID.IsEqual <Organization.bAccountID.FromCurrent> >
                    .View.SelectSingleBound(this, new object[] { org });

                Dictionary <string, string> parameters = new Dictionary <string, string>
                {
                    ["PayerBAccountID"] = orgBAccount?.AcctCD,
                    ["FinYear"]         = Year_Header.Current.FinYear
                };
                throw new PXReportRequiredException(parameters, "AP654500", Messages.Year1099DetailReport);
            }
            return(adapter.Get());
        }
        public void RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null || HideBranchField == false)
            {
                return;
            }

            int?organizationID = (int?)sender.GetValue(e.Row, OrganizationFieldType.Name);

            PXUIFieldAttribute.SetVisible(sender, _FieldName, organizationID != null &&
                                          OrganizationMaint.FindOrganizationByID(sender.Graph, organizationID).FileTaxesByBranches == true);
        }
        private void OrganizationRowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            bool         enableBranchSelector = true;
            int?         organizationID       = (int?)sender.GetValue(e.Row, OrganizationFieldType.Name);
            Organization organization         = OrganizationMaint.FindOrganizationByID(sender.Graph, organizationID);

            if (organization != null)
            {
                enableBranchSelector = organization.OrganizationType != OrganizationTypes.WithoutBranches;
            }

            PXUIFieldAttribute.SetEnabled(sender, _FieldName, enableBranchSelector);
        }
コード例 #6
0
        public virtual IEnumerable Open1099PaymentsReport(PXAdapter adapter)
        {
            if (Year_Header.Current != null)
            {
                Organization org = OrganizationMaint.FindOrganizationByID(this, Year_Header.Current.OrganizationID);

                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters["OrganizationID"] = org?.OrganizationCD;
                parameters["FinYear"]        = Year_Header.Current.FinYear;
                throw new PXReportRequiredException(parameters, "AP656500", "Open 1099 Payments");
            }
            return(adapter.Get());
        }
コード例 #7
0
        protected virtual void ShowOpenShipments(IEnumerable <FinPeriod> periods)
        {
            ParallelQuery <string> periodIDs = periods.Select(fp => fp.FinPeriodID).AsParallel();

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["FromPeriodID"] = FinPeriodIDFormattingAttribute.FormatForDisplay(periodIDs.Min());
            parameters["ToPeriodID"]   = FinPeriodIDFormattingAttribute.FormatForDisplay(periodIDs.Max());
            Organization org = OrganizationMaint.FindOrganizationByID(this, Filter.Current.OrganizationID);

            parameters["OrgID"] = org?.OrganizationCD;

            throw new PXReportRequiredException(parameters, "IN656500", PXBaseRedirectException.WindowMode.NewWindow, "Documents Not Posted to Inventory");
        }
コード例 #8
0
        public virtual IEnumerable Year1099DetailReport(PXAdapter adapter)
        {
            AP1099YearMaster filter = YearVendorHeader.Current;

            if (filter != null)
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                Organization org = OrganizationMaint.FindOrganizationByID(this, filter.OrganizationID);
                parameters["OrganizationID"] = org?.OrganizationCD;
                parameters["FinYear"]        = filter.FinYear;
                throw new PXReportRequiredException(parameters, "AP654500", Messages.Year1099DetailReport);
            }
            return(adapter.Get());
        }
コード例 #9
0
        public virtual void CanBeBranchesDeletedSeparately(IReadOnlyCollection <Branch> branches)
        {
            foreach (var branch in branches)
            {
                Graph.Caches[typeof(Branch)].ClearQueryCacheObsolete();

                Organization organization = OrganizationMaint.FindOrganizationByID(Graph, branch.OrganizationID);

                if (organization != null &&
                    organization.OrganizationType == OrganizationTypes.WithoutBranches)
                {
                    throw new PXException(Messages.TheBranchCannotBeDeletedBecauseItBelongsToTheCompanyOfTheWithoutBranchesType,
                                          branch.BranchCD.Trim(),
                                          organization.OrganizationCD.Trim());
                }
            }

            CanBeBranchesDeleted(branches);
        }
        protected virtual PXSetPropertyException CanBeLinkDeleted(OrganizationLedgerLink link)
        {
            Ledger ledger = GeneralLedgerMaint.FindLedgerByID(Base, link.LedgerID);

            if (ledger.BalanceType == LedgerBalanceType.Actual)
            {
                if (GLUtility.RelatedGLHistoryExists(Base, link.LedgerID, link.OrganizationID))
                {
                    Organization org = OrganizationMaint.FindOrganizationByID(Base, link.OrganizationID, true);
                    return(new PXSetPropertyException(Messages.TheRelationBetweenTheLedgerAndTheCompanyCannotBeRemovedBecauseAtLeastOneGeneralLedgerTransactionHasBeenPosted,
                                                      PXErrorLevel.RowError,
                                                      LinkCache.GetValueExt <OrganizationLedgerLink.ledgerID>(link),
                                                      org.OrganizationCD.Trim()
                                                      ));
                }
            }

            return(null);
        }
コード例 #11
0
        public virtual IEnumerable Open1099PaymentsReport(PXAdapter adapter)
        {
            if (Year_Header.Current != null)
            {
                Organization org = OrganizationMaint.FindOrganizationByID(this, Year_Header.Current.OrganizationID);

                BAccountR orgBAccount =
                    SelectFrom <BAccountR>
                    .Where <BAccountR.bAccountID.IsEqual <Organization.bAccountID.FromCurrent> >
                    .View.SelectSingleBound(this, new object[] { org });

                Dictionary <string, string> parameters = new Dictionary <string, string>
                {
                    ["OrgBAccountID"] = orgBAccount?.AcctCD,
                    ["FinYear"]       = Year_Header.Current.FinYear
                };
                throw new PXReportRequiredException(parameters, "AP656500", "Open 1099 Payments");
            }
            return(adapter.Get());
        }
        public void FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            int?organizationID = (int?)sender.GetValue(e.Row, OrganizationFieldType.Name);

            if (organizationID == null)
            {
                return;
            }

            Organization organization = OrganizationMaint.FindOrganizationByID(sender.Graph, organizationID);

            if (organization.FileTaxesByBranches == true)
            {
                e.NewValue = sender.Graph.Accessinfo.BranchID;
            }
        }
        public virtual IEnumerable deleteOrganizationLedgerLink(PXAdapter adapter)
        {
            var link = LinkCache.Current as OrganizationLedgerLink;

            if (link?.OrganizationID == null || link.LedgerID == null)
            {
                return(adapter.Get());
            }

            Ledger ledger = GeneralLedgerMaint.FindLedgerByID(Base, link.LedgerID);

            if (ledger.BalanceType == LedgerBalanceType.Actual)
            {
                LinkCache.Delete(link);
            }
            else
            {
                if (GLUtility.RelatedGLHistoryExists(Base, link.LedgerID, link.OrganizationID))
                {
                    Organization org = OrganizationMaint.FindOrganizationByID(Base, link.OrganizationID, true);

                    WebDialogResult dialogResult = OrganizationLedgerLinkSelect.Ask(PXMessages.LocalizeFormatNoPrefix(
                                                                                        Messages.AtLeastOneGeneralLedgerTransactionHasBeenPosted,
                                                                                        LinkCache.GetValueExt <OrganizationLedgerLink.ledgerID>(link).ToString().Trim(),
                                                                                        org.OrganizationCD.Trim()),
                                                                                    MessageButtons.YesNo);

                    if (dialogResult == WebDialogResult.Yes)
                    {
                        LinkCache.Delete(link);
                    }
                }
                else
                {
                    LinkCache.Delete(link);
                }
            }

            return(adapter.Get());
        }
        public void FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            int?organizationID = (int?)sender.GetValue(e.Row, OrganizationFieldType.Name);

            if (organizationID == null)
            {
                return;
            }

            Organization organization = OrganizationMaint.FindOrganizationByID(sender.Graph, organizationID);

            if (organization.FileTaxesByBranches != true && e.NewValue != null)
            {
                e.NewValue = null;
                e.Cancel   = true;
            }
        }
		protected virtual IEnumerable consolRecords(
			[PXDBString]
			string ledgerCD,
			[PXDBString]
			string branchCD
			)
		{
			Ledger ledger = PXSelect<Ledger,
				Where<Ledger.consolAllowed, Equal<True>,
				And<Ledger.ledgerCD, Equal<Required<Ledger.ledgerCD>>>>>.Select(this, ledgerCD);

			if (ledger == null)
			{
				throw new PXException(Messages.CantFindConsolidationLedger, ledgerCD);
			}

			Branch branch = PXSelect<Branch,
				Where<Branch.branchCD, Equal<Required<Branch.branchCD>>>>.Select(this, branchCD);

			if (!string.IsNullOrEmpty(branchCD) && branch == null)
			{
				throw new PXException(Messages.CantFindConsolidationBranch, branchCD);
			}

			if (branch != null && ledger.BalanceType != LedgerBalanceType.Report)
			{
				Organization organization = OrganizationMaint.FindOrganizationByID(this, branch.OrganizationID);

				if (organization.OrganizationType == OrganizationTypes.WithBranchesNotBalancing)
				{
					throw new PXException(Messages.BranchCannotBeConsolidated, branchCD);
				}
			}

			var exportSubaccountMapper = CreateExportSubaccountMapper();

			var noSegmentsToExport = false;
			if (PXAccess.FeatureInstalled<FeaturesSet.subAccount>())
			{
				noSegmentsToExport = SubaccountSegmentsView.Select()
					.RowCast<Segment>()
					.All(segment => segment.ConsolNumChar <= 0);
			}

			PXSelectBase<GLHistory> cmd = new PXSelectJoin<GLHistory,
				InnerJoin<Account, On<Account.accountID, Equal<GLHistory.accountID>>,
				InnerJoin<Sub, On<Sub.subID, Equal<GLHistory.subID>>,
				InnerJoin<Ledger, On<Ledger.ledgerID, Equal<GLHistory.ledgerID>>,
				InnerJoin<Branch, On<Branch.branchID, Equal<GLHistory.branchID>>>>>>,
				Where<Ledger.ledgerCD, Equal<Required<Ledger.ledgerCD>>,
				And<GLHistory.accountID, NotEqual<Current<GLSetup.ytdNetIncAccountID>>>>,
				OrderBy<Asc<GLHistory.finPeriodID, Asc<Account.accountCD, Asc<Sub.subCD>>>>>(this);

			if (!string.IsNullOrEmpty(branchCD))
			{
				cmd.WhereAnd<Where<Branch.branchCD, Equal<Required<Branch.branchCD>>>>();
			}

			foreach (PXResult<GLHistory, Account, Sub> result in cmd.Select(ledgerCD, branchCD))
			{
				GLHistory history = result;
				Account account = result;
				Sub sub = result;

				string accountCD = account.GLConsolAccountCD;
				string subCD = exportSubaccountMapper.GetMappedSubaccountCD(sub);

				if (accountCD != null && accountCD.TrimEnd() != ""
					&& (subCD != null && subCD.TrimEnd() != "" || noSegmentsToExport))
				{
					GLConsolData consolData = new GLConsolData();
					consolData.MappedValue = subCD;
					consolData.AccountCD = accountCD;
					consolData.FinPeriodID = history.FinPeriodID;
					consolData = ConsolRecords.Locate(consolData);
					if (consolData != null)
					{
						consolData.ConsolAmtDebit += history.FinPtdDebit;
						consolData.ConsolAmtCredit += history.FinPtdCredit;
					}
					else
					{
						consolData = new GLConsolData();
						consolData.MappedValue = subCD;
						consolData.MappedValueLength = subCD.Length;
						consolData.AccountCD = accountCD;
						consolData.FinPeriodID = history.FinPeriodID;
						consolData.ConsolAmtDebit = history.FinPtdDebit;
						consolData.ConsolAmtCredit = history.FinPtdCredit;
						ConsolRecords.Insert(consolData);
					}
				}
			}

			return ConsolRecords.Cache.Inserted;
		}
コード例 #16
0
        protected virtual void baseTaxPeriodFilterRowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            VATPeriodFilter filter = (VATPeriodFilter)e.Row;

            if (filter == null)
            {
                return;
            }

            if (!sender.ObjectsEqual <VATPeriodFilter.organizationID, VATPeriodFilter.branchID>(e.Row, e.OldRow))
            {
                List <PXView> views = this.Views.Select(view => view.Value).ToList();
                foreach (var view in views)
                {
                    view.Clear();
                }
            }

            if (!sender.ObjectsEqual <VATPeriodFilter.organizationID>(e.Row, e.OldRow) ||
                !sender.ObjectsEqual <VATPeriodFilter.branchID>(e.Row, e.OldRow) ||
                !sender.ObjectsEqual <VATPeriodFilter.vendorID>(e.Row, e.OldRow))
            {
                if (filter.OrganizationID != null && filter.VendorID != null)
                {
                    PX.Objects.TX.TaxPeriod taxper = TaxYearMaint.FindPreparedPeriod(this, filter.OrganizationID, filter.VendorID);

                    if (taxper != null)
                    {
                        filter.TaxPeriodID = taxper.TaxPeriodID;
                    }
                    else
                    {
                        taxper             = TaxYearMaint.FindLastClosedPeriod(this, filter.OrganizationID, filter.VendorID);
                        filter.TaxPeriodID = taxper != null ? taxper.TaxPeriodID : null;
                    }
                }
                else
                {
                    filter.TaxPeriodID = null;
                }
            }

            Organization organization = OrganizationMaint.FindOrganizationByID(this, filter.OrganizationID);

            if (!sender.ObjectsEqual <VATPeriodFilter.organizationID>(e.Row, e.OldRow) ||
                !sender.ObjectsEqual <VATPeriodFilter.branchID>(e.Row, e.OldRow) ||
                !sender.ObjectsEqual <VATPeriodFilter.vendorID>(e.Row, e.OldRow) ||
                !sender.ObjectsEqual <VATPeriodFilter.taxPeriodID>(e.Row, e.OldRow) ||
                filter.RevisionId == null)
            {
                if (filter.OrganizationID != null &&
                    (filter.BranchID != null && organization.FileTaxesByBranches == true || organization.FileTaxesByBranches != true) &&
                    filter.VendorID != null && filter.TaxPeriodID != null)
                {
                    filter.RevisionId = ReportTaxProcess.CurrentRevisionId(this, filter.OrganizationID, filter.BranchID, filter.VendorID, filter.TaxPeriodID);
                }
                else
                {
                    filter.RevisionId = null;
                }
            }
        }