Numbers, tables and totals / Discount and surcharge lines
Discount and surcharge lines that read correctly on paper
Rows that reduce or increase the amount without being goods or services, which have to be legible as adjustments rather than as more items.
Why this block is harder than it looks
A discount is arithmetically a negative line and visually not a line at all. Put it in the items table as a row with a minus sign and it reads as a product that costs less than nothing. Put it in the totals block and it stops being attributable to anything, so a customer querying the discount has nowhere to look. The same applies in the other direction for a delivery charge or a late fee. There is also the question of whether the adjustment applies before or after tax, which changes both the arithmetic and where the row has to sit.
The decisions that make it work
Reasons rather than a description of the code. Each of these is a choice that has a wrong answer, and the wrong answer is usually the default.
- Place a document-level adjustment between the items table and the totals, in its own band, not as a table row and not inside the totals block.
- Place a line-level discount on the line it belongs to, as a second smaller line under the description rather than as a separate row, so it cannot be separated from what it discounts.
- Show the basis as well as the result. Ten percent off is not a figure, and 418.00 with no percentage beside it is not checkable. Print both.
- Use a real minus sign rather than a hyphen. At small sizes a hyphen next to a digit reads as punctuation in the description and gets missed entirely.
- Never rely on colour to indicate a reduction. Red for negative is invisible in monochrome, and monochrome is how most of these are printed.
- State whether the adjustment is applied before or after tax, once, near the block. Every reader who cares looks for it and every reader who does not will not notice the line.
The fragment
Markup and the CSS it needs, and nothing else. It expects a document that already has a page rule and a base stylesheet, so paste it into one rather than opening it on its own.
<section class="adjustments">
<div class="adj">
<span class="label">Volume discount, 10% of net</span>
<span class="v">−418.00</span>
</div>
<div class="adj">
<span class="label">Delivery, next day</span>
<span class="v">36.00</span>
</div>
<p class="note">Adjustments apply to the net amount, before tax.</p>
</section>
<style>
.adjustments {
break-inside: avoid;
margin: 8pt 0;
padding: 6pt 0;
border-top: 0.5pt solid #ccc;
border-bottom: 0.5pt solid #ccc;
}
.adjustments .adj {
display: flex;
justify-content: space-between;
padding: 2pt 0;
}
.adjustments .v {
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.adjustments .note { margin-top: 4pt; font-size: 8pt; color: #555; }
</style>What breaks when it is built the obvious way
A negative row inside the items table, styled like the items. It sums correctly and it reads wrongly, and on a printed copy handed to somebody in accounts payable it is the line that generates the query. The arithmetic being right is not the same as the document being right.
How to prove it survived pagination
Print it in greyscale and hand it to somebody who did not build it. Ask what the total would be without the adjustment. If they have to ask whether the discount was before or after tax, the note is missing or too small.
Where it sits in a finished document
This page is one block. The document it belongs to has a page rule, a base stylesheet, a header and everything else around it, and repeating all of that here would make thirty pages that say the same thing. The quotation template is a complete file with this block already in it, so take that and change the fragment rather than assembling one from parts. The property doing most of the work here is covered on its own page, with the support caveats that belong there rather than here.
Frequently asked
Will this fragment work on its own?
Not as a whole document. It has no page rule, no margins and no base type, because those belong to the document rather than to the block, and duplicating them in every fragment would mean thirty copies to keep in step. Paste it into a template that already has them.
Why does it look right in a browser and wrong in the PDF?
Because a browser window is one continuous surface and a document is a stack of fixed rectangles. Nothing in a scrolling view exercises a page boundary, so every break rule in the fragment is inert until the content is paginated. Render the real thing with enough content to cross two or three boundaries, then look.
Do I need a special option on the render request for this?
No. Everything on this page is CSS and markup, which is your side of the boundary. What the render has to give you is a real page size with real margins, and after that the layout is decided by the stylesheet.
Other parts of a document
The blocks that sit next to this one, and one from the next group along so you are not sealed inside a single kind of problem.
Carried forward and brought forward totals on a long table
The running figure printed at the foot of each page and repeated at the top of the next, so a multi-page table can be checked page by page instead of only at the end.
A running balance column that stays readable over many pages
A column on a transaction table showing the balance after each movement, which turns a list of events into something a reader can audit line by line.
Quantity, unit and unit-price columns that do not wrap
The three narrow columns between the description and the amount, which are the first things to break when a description gets long or a unit of measure gets spelled out.
A delivery details block with dates, carrier and terms
Dispatch date, expected arrival, carrier, consignment reference and delivery terms, gathered into one block near the top of a despatch document.
Quotation, as a complete file
The whole document with this block already in place, ready to copy and change.
break-inside in paged output
The property carrying the weight here, with its real support status.
Every part of a document
The full list, grouped by the kind of problem the block poses.
Paste the fragment into the playground inside a page rule and see what it does at a real page size. That is the only way any of this gets confirmed.