Example #1
0
        public virtual FABookPeriod.Key GetKeyFromReportParameters(
            PXGraph graph,
            object[] parameters,
            ReportParametersFlag reportParametersMask)
        {
            ParameterEvaluator <ReportParametersFlag> parameterEvaluator = new ParameterEvaluator <ReportParametersFlag>(reportParametersMask, parameters);

            HashSet <int?> branchIDs = new HashSet <int?>();
            int?           branchID  = (int?)parameterEvaluator[ReportParametersFlag.Branch];

            if (branchID != null)
            {
                branchIDs.Add(branchID);
            }
            branchIDs.AddRange(PXAccess.GetBranchIDsByBAccount((int?)parameterEvaluator[ReportParametersFlag.BAccount]).Cast <int?>());

            FAKeyWithSourceValues keyWithSourceValuesItem = EvaluateRawKey(graph,
                                                                           new FAKeyWithSourceValues()
            {
                SpecificationItem     = CachedSourcesSpecification.MainSpecificationItem,
                SourceOrganizationIDs = ((int?)parameterEvaluator[ReportParametersFlag.Organization]).SingleToList(),
                SourceBranchIDs       = branchIDs.ToList(),
                SourceAssetIDs        = ((int?)parameterEvaluator[ReportParametersFlag.FixedAsset]).SingleToList(),
                SourceBookIDs         = ((int?)parameterEvaluator[ReportParametersFlag.Book]).SingleToList()
            });

            if (keyWithSourceValuesItem.Key.OrganizationID == null && UseMasterOrganizationIDByDefault)
            {
                keyWithSourceValuesItem.Key.OrganizationID = MasterValue;
            }

            return(keyWithSourceValuesItem.Key);
        }
Example #2
0
        protected override FAKeyWithSourceValues CollectSourceValues(
            PXGraph graph, PXCache attributeCache, object extRow, FASourceSpecificationItem specificationItem)
        {
            if (specificationItem == null)
            {
                return(null);
            }

            FAKeyWithSourceValues valuesCollectionItem =
                base.CollectSourceValues(graph, attributeCache, extRow, specificationItem);

            valuesCollectionItem.SourceAssetIDs =
                GetAssetIDsValueFromField(graph, attributeCache, extRow, specificationItem).SourceAssetIDs;

            valuesCollectionItem.SourceBookIDs =
                GetBookIDsValueFromField(graph, attributeCache, extRow, specificationItem).SourceBookIDs;

            return(valuesCollectionItem);
        }
Example #3
0
        protected override FAKeyWithSourceValues EvaluateRawKey(PXGraph graph,
                                                                FAKeyWithSourceValues keyWithSourceValues)
        {
            if (keyWithSourceValues == null)
            {
                return(null);
            }

            FABook book = BookMaint.FindByID(graph, keyWithSourceValues.SourceBookIDs.First());

            if (book == null)
            {
                if (keyWithSourceValues.SpecificationItem.IsBookRequired)
                {
                    return(keyWithSourceValues);
                }
                else
                {
                    book = BookMaint.FindByBookMarker(graph, FABook.bookID.Markers.GLOrAnyBook);
                }
            }

            if (book == null)
            {
                return(keyWithSourceValues);
            }

            keyWithSourceValues.Key.SetBookID(book);

            if (book.UpdateGL == true)
            {
                if (!PXAccess.FeatureInstalled <FeaturesSet.branch>())
                {
                    keyWithSourceValues.KeyOrganizationIDs = PXAccess.GetParentOrganizationID(PXAccess.GetBranchID()).SingleToList();
                }
                else
                {
                    keyWithSourceValues.KeyOrganizationIDs = keyWithSourceValues.SourceOrganizationIDs;

                    if (IsIDsUndefined(keyWithSourceValues.KeyOrganizationIDs))
                    {
                        if (!IsIDsUndefined(keyWithSourceValues.SourceBranchIDs))
                        {
                            keyWithSourceValues.KeyOrganizationIDs =
                                keyWithSourceValues.SourceBranchIDs
                                .Select(branchID => PXAccess.GetParentOrganizationID(branchID))
                                .ToList();
                        }
                        else
                        {
                            if (!IsIDsUndefined(keyWithSourceValues.SourceAssetIDs))
                            {
                                keyWithSourceValues.KeyOrganizationIDs =
                                    keyWithSourceValues.SourceAssetIDs
                                    .Select(assetID => PXAccess.GetParentOrganizationID(AssetMaint.FindByID(graph, assetID)?.BranchID))
                                    .ToList();
                            }
                            else if (!PXAccess.FeatureInstalled <FeaturesSet.multipleCalendarsSupport>())
                            {
                                keyWithSourceValues.KeyOrganizationIDs =
                                    ((int?)FABookPeriod.organizationID.NonPostingBookValue).SingleToList();
                            }
                        }
                    }
                }
            }
            else
            {
                keyWithSourceValues.KeyOrganizationIDs =
                    ((int?)FABookPeriod.organizationID.NonPostingBookValue).SingleToList();
            }

            keyWithSourceValues.Key.OrganizationID = keyWithSourceValues.KeyOrganizationIDs.First();

            return(keyWithSourceValues);
        }