Why your SAP Business One sales report doesn't match: the header discount in INV1
By Zain Abbas, Kodenova · Updated
Why doesn’t my SAP Business One sales report match SAP?
Usually because the report sums invoice lines and ignores the discount typed in the invoice footer. INV1.LineTotal is after the row discount but before the header discount, which SAP Business One stores on OINV as DiscPrcnt and DiscSum. In our test the line sum was 49,085.44 against SAP’s 49,058.00, and the 27.44 gap was that footer discount.
You build a sales report, a dashboard or a Power BI model from SAP Business One. The total is close to the SAP figure, but not equal. Accounting does not trust the dashboard, and they are right not to.
We hit this while testing the Kodenova SAP B1 dashboard on a live company. The first version summed invoice lines and returned 49,085.44. SAP’s own figure for the same period was 49,058.00. The 27.44 difference came from one thing: a discount typed in the invoice footer.
Why does a sum of INV1.LineTotal overstate sales?
SAP Business One stores an A/R invoice at two levels. INV1 holds the lines, with LineTotal after the row discount. OINV holds the header, including DiscPrcnt and DiscSum for the document discount. The footer discount applies to the whole document and is not written back into each line, so a sum of the lines is still before that discount.
An A/R invoice stores values at two levels:
- INV1 (lines):
LineTotal,GrssProfit,Quantity. LineTotal is after the row discount. - OINV (header):
DiscPrcntandDiscSumfor the document discount, plusDocTotal,VatSumandTotalExpns. See the OINV table fields and joins.
The footer discount is applied to the whole document, not written back into each line. So when you SUM(T1."LineTotal"), you add up values that are still before that discount. Most invoices have no footer discount, which is why the error is small and easy to miss.
How do you apply the header discount in SQL?
Join each INV1 line to its OINV header, group per document and take DiscPrcnt along. Then net after discount is Net minus Net × DiscPrcnt / 100, and gross profit after discount is GP minus the same amount. Run the same query on ORIN and RIN1 for credit notes, treat them as negative, and leave out cancelled invoices.
Bring the header discount into the line query and apply it per document:
SELECT T0."DocEntry", T0."DocDate", T0."CardCode", T0."DiscPrcnt",
T1."ItemCode",
SUM(T1."LineTotal") AS "Net",
SUM(T1."GrssProfit") AS "GP"
FROM OINV T0
INNER JOIN INV1 T1 ON T0."DocEntry" = T1."DocEntry"
WHERE T0."CANCELED" = 'N' AND T0."DocDate" >= '20250101'
GROUP BY T0."DocEntry", T0."DocDate", T0."CardCode", T0."DiscPrcnt", T1."ItemCode"
Then, for each row:
- net after discount =
Net − Net × DiscPrcnt / 100 - gross profit after discount =
GP − Net × DiscPrcnt / 100
Run the same query on ORIN and RIN1 for credit notes and treat those values as negative.
We apply the percentage in code rather than in SQL because some environments, such as Service Layer SQLQueries with a restricted allow-list, reject expressions in the select list. If your environment allows arithmetic, you can do it directly in SQL.
How to check your number against SAP
Before you trust any report, reconcile it once with a header-level query. Net sales excluding VAT and freight is:
SELECT
(SELECT SUM(T0."DocTotal" - T0."VatSum" - T0."TotalExpns")
FROM OINV T0 WHERE T0."CANCELED" = 'N' AND T0."DocDate" >= '20250101')
-
(SELECT ISNULL(SUM(T0."DocTotal" - T0."VatSum" - T0."TotalExpns"), 0)
FROM ORIN T0 WHERE T0."CANCELED" = 'N' AND T0."DocDate" >= '20250101')
On SAP HANA, use IFNULL instead of ISNULL. In our test this returned 49,058.00, exactly what the corrected line query gave.
Small differences can still appear if documents use rounding or down payments, because those also live on the header. If you see a gap, look at those fields next.
Checklist for any SAP B1 sales report
- Filter
CANCELED = 'N'. - Subtract credit notes (ORIN/RIN1).
- Apply the header discount to both net sales and gross profit.
- Use one currency field consistently (
LineTotalfor local currency). - Reconcile once against
DocTotal − VatSum − TotalExpnsbefore going live.
Ready-made queries that apply this fix, either by reading header totals or by applying the discount factor to the lines: Sales by customer for a date range, Top 20 selling items, Sales by sales employee and Monthly sales trend.
Where this matters most
Any tool that reads lines instead of headers is exposed: Excel exports, Crystal Reports, Power BI models and custom dashboards. The Kodenova SAP B1 dashboard applies the header discount automatically through its local connector, so its totals match the SAP figures above.
If your reports and SAP disagree and you cannot find why, send us the query. This kind of mismatch is usually found in one session.
Sources
- SAP Learning: Managing SQL Queries Using Service Layer API
- SAP Learning: Creating Queries (SAP Business One)
Related services
Frequently asked questions
Is INV1.LineTotal before or after the document discount?
Before. LineTotal is the row total after the row discount but before the discount entered in the document footer. That footer discount is stored on the header as DiscPrcnt (percentage) and DiscSum (amount).
Does GrssProfit include the header discount?
GrssProfit is calculated per row, so a line-level sum does not see the footer discount. We subtract the discount amount from gross profit as well as from net sales. To confirm on your data, compare with the header field OINV.GrosProfit for a discounted invoice.
Should credit notes be subtracted?
Yes. A sales report that ignores ORIN and RIN1 overstates revenue. Treat credit-note lines as negative values and apply their own header discount the same way.
Should cancelled invoices be included?
No. Filter on CANCELED = 'N'. A cancelled invoice and its cancellation document both carry a CANCELED flag ('Y' and 'C'), and including either one distorts totals.
Is the result in local currency?
LineTotal is in local currency. TotalFrgn holds the foreign-currency value. Use one consistently and label the report with the currency.
Ready to get started?
Tell us what you need. You get a clear technical answer, a fixed scope and a price, usually within 24 hours.
