microsoft / microsoft/BCApps

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

Open
#8,869 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Approved Team: Integrations
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read GetGoodsAndServicesText() in StandardSalesInvoice.Report.al, StandardSalesCreditMemo.Report.al, and StandardSalesDraftInvoice.Report.al, starting with the Type filter and the associated line records. Reproduce the case with an Item line and a blank/Comment line, then verify that posted invoices and credit memos report only goods and that mixed goods-and-services documents still report both.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.