Skip to content

0.8.0

Choose a tag to compare

@FernandoCelmer FernandoCelmer released this 07 Sep 23:39
· 18 commits to main since this release

What's Changed

  • UnitPrice on a product — the price of one unit, beside Amount, the line's gross total

Why

Amount has always been the line's gross total, but a reader sees {Quantity: 2, Amount: 120.00} and expects R$ 240,00. The API answered R$ 120,00, and the mistake only surfaced on an authorized document. There was no field that meant "what one unit costs", so the API derived it by dividing — in float, at the tenth decimal place the SEFAZ reads.

price := 120.00

br.Product{
	Description: "Teclado",
	Quantity:    2,
	UnitPrice:   &price,
	Unit:        "UN",
	NCM:         ptr("84716052"),
	CFOP:        ptr("5102"),
}

Send UnitPrice or Amount. Sending both asserts they agree: the API compares quantity x unit_price against amount and refuses the document before transmission if they differ, naming the line and both numbers.

Both now travel as strings on the wire, so a ten-place unit price reaches the API exactly as typed rather than in exponent form. Amount stays a plain float64 and is omitted when it is zero, so no existing call site changes.

Amount keeps the meaning it always had and is not deprecated — nothing has to migrate.