microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
748 stars 600 forks source link

[Extensibility Request] Bug? Codeunit 7002 - FindLines #24424

Open chrischbo opened 10 months ago

chrischbo commented 10 months ago

Hi,

is it possible to adjust the logic to get all price list lines if ShowAll is true? At the moment the FindLines procedure ignores the ShowAll parameter and will always exit the procedure if a price list line is found (FoundLines = true) If you're working with levels it will always end the procedure at toplevel when a price is found but we want all price list lines and so we're running FindLines with ShowAll set to true.

Wouldn't it be better to take "ShowAll" into account on looping thru the price list lines? Something like this:

        PriceCalculationBufferMgt.SetFiltersOnPriceListLine(PriceListLine, AmountType, ShowAll);
        PriceCalculationBufferMgt.GetAssets(PriceAssetList);
        PriceCalculationBufferMgt.GetSources(PriceSourceList);
        OnFindLinesOnBefoerPriceSourceListGetMinMaxLevel(PriceAssetList, PriceSourceList, AmountType, PriceCalculationBufferMgt);
        PriceSourceList.GetMinMaxLevel(Level);
        for CurrLevel := Level[2] downto Level[1] do
            if ShowAll or (not FoundLines) then
                if PriceSourceList.First(PriceSource, CurrLevel) then
                    repeat
                        if PriceSource.IsForAmountType(AmountType) then begin
                            FoundLines :=
                                FoundLines or CopyLinesBySource(PriceListLine, PriceSource, PriceAssetList, TempPriceListLine);
                            PriceCalculationBufferMgt.RestoreFilters(PriceListLine);
                        end;
                    until not PriceSourceList.Next(PriceSource);

        FoundLines := not TempPriceListLine.IsEmpty();
        if Not FoundLines then
            PriceCalculationBufferMgt.FillBestLine(AmountType, TempPriceListLine);

What is the intendet solution to show all price list lines at e.g. SalesInfoPane - CountPrice?

Kind regards, Christian

JakovljevicDusan commented 2 months ago

Hi @chrischbo ,

Please add more details on this request. It is obviously related to #24423. What is shown OnDrillDown of SalesPrices in page 9087 "Sales Line FactBox"?

chrischbo commented 2 months ago

Hi @JakovljevicDusan this is right. With the requested publisher we could fix this problem by our self but in general it is a problem with the ShowAll flag if you work with hierarchical level price source. The procedure will end if a price is found on a level and the ShowAll flag is totally ignored. So if you run function like CountPrice the count will end up with only the first found price line and everything else is "lost". Taking the example from here: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extending-best-price-calculations#example-add-hierarchical-price-calculations This will end up with only counting the toplevel prices (Customer in this case) so the other price lines will not be counted.