Skip to content

[Bug]: GetGoodsAndServicesText calculates that the document contains services if there is at least one comment line #8869

Description

@nicolassaleron

Describe the issue

The local procedure GetGoodsAndServicesText() determines whether a posted sales document contains goods, services, or a mix of both, in order to print the appropriate label on the document layout.

The procedure first filters out lines of type Item to detect service lines. However, the filter <> Item also matches blank/comment lines (type " "), which are not goods nor services. As a result, any document that contains at least one comment line is incorrectly reported as containing services.

Affected code (identical pattern in both reports):

SalesInvoiceLine.SetFilter(Type, '<> %1', SalesInvoiceLine.Type::Item);
if not SalesInvoiceLine.IsEmpty() then
    GotServices := true;

Because Type::" " (comment/blank) satisfies the filter <> Item, GotServices is set to true even when the document has only inventory items and comment lines.

Expected behavior

Comment lines (type " ") should be ignored when determining whether a document contains goods or services. A sales invoice or credit memo that contains only inventory items and comment lines should print:

Sales invoice includes only goods.

Steps to reproduce

  1. Open Business Central and navigate to Sales > Orders (or Sales > Invoices).
  2. Create a new sales order/invoice.
  3. Add a line of type Item with an inventory item.
  4. Add a second line of type Comment (leave the Type field blank and enter any description).
  5. Post the document.
  6. Print the posted sales invoice using the Standard Sales - Invoice report.

Observed result: The printed document shows "Sales invoice includes goods and services."

Expected result: The printed document should show "Sales invoice includes only goods."

The same steps apply to sales credit memos printed with the Standard Sales - Credit Memo report.

Additional context

The fix requires excluding comment/blank lines from the service detection filter in GetGoodsAndServicesText() in both reports. The filter on the first pass should be changed to exclude both Item and " " (blank) line types:

// Current (buggy):
SalesInvoiceLine.SetFilter(Type, '<> %1', SalesInvoiceLine.Type::Item);

// Fixed:
SalesInvoiceLine.SetFilter(Type, '<> %1 & <> %2', SalesInvoiceLine.Type::Item, SalesInvoiceLine.Type::" ");

This change must be applied in:

  • GetGoodsAndServicesText() in StandardSalesInvoice.Report.al (using SalesInvoiceLine: Record "Sales Invoice Line")
  • GetGoodsAndServicesText() in StandardSalesCreditMemo.Report.al (using SalesCrMemoLine: Record "Sales Cr.Memo Line")
  • GetGoodsAndServicesText() in StandardSalesDraftInvoice.Report.al (using SalesLine: Record "Sales Line")

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM area

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions