Class PostingEngine

java.lang.Object
com.onec.posting.PostingEngine

public class PostingEngine extends Object
Posts documents: runs their Postable logic, writes the resulting register movements and totals, enforces non-negative balances, then flips _posted.

Transaction boundary — important

Posting runs inside its own JDBI transaction (Jdbi.useTransaction(org.jdbi.v3.core.HandleConsumer<X>)) on a connection obtained directly from the DataSource. It is not enlisted in any ambient Spring @Transactional that the caller may have opened. Two consequences follow:
  • Do not wrap "save the document, then post it" in a single @Transactional method. The save() row is not yet committed, so JDBI — on a separate connection — cannot see it, the UPDATE ... SET _posted = TRUE matches zero rows, and you silently get register movements with _posted still false. Save (and let it commit) first, then call PostingService/post(...).
  • Posting is atomic in itself (movements, totals, balance checks and the _posted flag all commit or roll back together), but it is a distinct transaction from the document write.