Skip to content

[Extensibility][SubscriptionBilling] Make usage data billing filtering in SetUsageDataBillingFilters extensible for custom "Usage Based Pricing" enum values #9223

Description

@miljance

Describe the issue

In SubscriptionLine.Table.al, the local procedure SetUsageDataBillingFilters filters usage data billing records with a bounded enum range:

UsageDataBilling.SetRange("Usage Base Pricing", Enum::"Usage Based Pricing"::"Usage Quantity", Enum::"Usage Based Pricing"::"Unit Cost Surcharge");

This SetRange(field, from, to) relies on the ordinal boundaries of enum 8007 "Usage Based Pricing" (ordinals Usage Quantity = 1 through Unit Cost Surcharge = 3). If a partner extends enum 8007 with custom option values above Unit Cost Surcharge, those values fall outside the assumed upper bound and are silently excluded from the filter, which can leave the returned UsageDataBilling recordset empty. This is an extensibility/design limitation: partners who extend the pricing enum cannot obtain correct filtering behavior, and there is no hook to adjust the filters that SetUsageDataBillingFilters applies.

Two things are needed:

  1. Change the SetRange("Usage Base Pricing", ...) call so it no longer assumes the enum ends at Unit Cost Surcharge. It should include the range Usage Quantity..Unit Cost Surcharge plus all values greater than Unit Cost Surcharge, so custom option values added above Unit Cost Surcharge are not excluded.
  2. Add an integration event at the end of SetUsageDataBillingFilters so partners can further adjust or extend the filters applied to UsageDataBilling.

Proposed change

  1. Replace the ordinal-bounded SetRange in SetUsageDataBillingFilters with filtering that covers Usage Quantity..Unit Cost Surcharge and everything above Unit Cost Surcharge (for example a SetFilter on the ordinal range plus > Unit Cost Surcharge, or otherwise avoiding the hard upper bound), so custom enum values are not dropped.
  2. Add a new [IntegrationEvent(false, false)] publisher (e.g. OnAfterSetUsageDataBillingFilters) raised at the end of SetUsageDataBillingFilters, passing var UsageDataBilling, the source SubscriptionLine record, and the BillingFromDate / BillingToDate parameters, so subscribers can add or modify filters.

Expected behavior

A dependent extension that adds custom values to enum 8007 "Usage Based Pricing" (once the enum is extensible) gets those records included by the built-in filter instead of an empty recordset, and can subscribe to the new integration event to refine the filters applied to UsageDataBilling — without needing to override or replace the base filtering logic.

Steps to reproduce

not applicable

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApprovedThe issue is approvedFinanceGitHub request for Finance area

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions