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
- Open Business Central and navigate to Sales > Orders (or Sales > Invoices).
- Create a new sales order/invoice.
- Add a line of type Item with an inventory item.
- Add a second line of type Comment (leave the Type field blank and enter any description).
- Post the document.
- 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
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
Itemto detect service lines. However, the filter<> Itemalso 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):
Because
Type::" "(comment/blank) satisfies the filter<> Item,GotServicesis set totrueeven 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:Steps to reproduce
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 bothItemand" "(blank) line types:This change must be applied in:
GetGoodsAndServicesText()in StandardSalesInvoice.Report.al (usingSalesInvoiceLine: Record "Sales Invoice Line")GetGoodsAndServicesText()in StandardSalesCreditMemo.Report.al (usingSalesCrMemoLine: Record "Sales Cr.Memo Line")GetGoodsAndServicesText()in StandardSalesDraftInvoice.Report.al (usingSalesLine: Record "Sales Line")I will provide a fix for a bug