• bitcoinBitcoin(BTC)$80,671.001.04%
  • Midas Fasanara Global EuroMidas Fasanara Global Euro(MGLOEURO)$111,813.00-0.36%
  • ethereumEthereum(ETH)$2,341.671.60%
  • tetherTether(USDT)$1.000.01%
  • binancecoinBNB(BNB)$746.720.83%
  • rippleXRP(XRP)$1.322.37%
  • usd-coinUSDC(USDC)$1.000.00%
  • solanaSolana(SOL)$101.000.80%
  • tronTRON(TRX)$0.3312000.47%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.02-2.05%
  • zcashZcash(ZEC)$1,297.126.34%
  • HyperliquidHyperliquid(HYPE)$81.114.61%
  • dogecoinDogecoin(DOGE)$0.0783361.67%
  • moneroMonero(XMR)$602.821.51%
  • USDSUSDS(USDS)$1.000.00%
  • whitebitWhiteBIT Coin(WBT)$77.501.12%
  • chainlinkChainlink(LINK)$11.461.22%
  • leo-tokenLEO Token(LEO)$9.040.18%
  • cardanoCardano(ADA)$0.2047790.21%
  • nearNEAR Protocol(NEAR)$4.623.86%
  • stellarStellar(XLM)$0.1698711.28%
  • bitcoin-cashBitcoin Cash(BCH)$288.964.01%
  • RainRain(RAIN)$0.007187-5.22%
  • Ethena USDeEthena USDe(USDE)$1.000.02%
  • daiDai(DAI)$1.00-0.02%
  • litecoinLitecoin(LTC)$56.710.48%
  • uniswapUniswap(UNI)$7.050.02%
  • avalanche-2Avalanche(AVAX)$8.86-0.17%
  • CantonCanton(CC)$0.098036-0.38%
  • USD1USD1(USD1)$1.000.01%
  • suiSui(SUI)$0.921.92%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.210.14%
  • hedera-hashgraphHedera(HBAR)$0.075960-0.48%
  • tether-goldTether Gold(XAUT)$4,052.370.95%
  • Global DollarGlobal Dollar(USDG)$1.00-0.01%
  • paypal-usdPayPal USD(PYUSD)$1.000.02%
  • BittensorBittensor(TAO)$253.151.59%
  • quant-networkQuant(QNT)$199.45-0.97%
  • shiba-inuShiba Inu(SHIB)$0.0000050.61%
  • EthenaEthena(ENA)$0.2089861.23%
  • crypto-com-chainCronos(CRO)$0.053162-0.11%
  • Ripple USDRipple USD(RLUSD)$1.00-0.03%
  • BitwayBitway(BTW)$1.6444.37%
  • MemeCoreMemeCore(M)$1.0712.50%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.150.00%
  • Circle USYCCircle USYC(USYC)$1.140.01%
  • okbOKB(OKB)$109.300.40%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • aaveAave(AAVE)$132.47-1.46%
  • OndoOndo(ONDO)$0.4156320.89%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

Designing a Schema-Guided Invoice Intelligence Pipeline with lift-pdf for Accounts-Payable Extraction, Validation, and Ledger Generation

July 3, 2026
in AI & Technology
Reading Time: 3 mins read
A A
Designing a Schema-Guided Invoice Intelligence Pipeline with lift-pdf for Accounts-Payable Extraction, Validation, and Ledger Generation
ShareShareShareShareShare
def render_pdf(d, path):
   """Draw a realistic one-page invoice: header, meta, bill/ship, line items, totals, payment."""
   from reportlab.lib.pagesizes import LETTER
   from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
   from reportlab.lib.units import inch
   from reportlab.lib import colors
   from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer,
                                   Table, TableStyle)
   c   = compute(d)
   sym = d["currency_symbol"]
   def money(x): return f"{sym}{x:,.2f}"
   ss   = getSampleStyleSheet()
   H1   = ParagraphStyle("H1",   parent=ss["Title"],    fontSize=18, leading=22, spaceAfter=2)
   SMALL= ParagraphStyle("SM",   parent=ss["Normal"],   fontSize=8.5, textColor=colors.grey, leading=11)
   LBL  = ParagraphStyle("LBL",  parent=ss["Normal"],   fontSize=8.5, textColor=colors.HexColor("#2b3a67"),
                         spaceAfter=1, fontName="Helvetica-Bold")
   BODY = ParagraphStyle("BODY", parent=ss["Normal"],   fontSize=9.5, leading=13)
   RIGHT= ParagraphStyle("R",    parent=ss["Normal"],   fontSize=16, leading=18, alignment=2,
                         textColor=colors.HexColor("#2b3a67"), fontName="Helvetica-Bold")
   story = []
  
   head = Table([[
       [Paragraph(d["vendor_name"], H1), Paragraph(d["vendor_address"], SMALL)],
       [Paragraph("INVOICE", RIGHT),
        Paragraph(f"{d['invoice_number']}", ParagraphStyle('n', parent=SMALL, alignment=2, fontSize=9.5))],
   ]], colWidths=[4.2 * inch, 2.8 * inch])
   head.setStyle(TableStyle([("VALIGN", (0, 0), (-1, -1), "TOP")]))
   story += [head, Spacer(1, 10)]
  
   meta_rows = [["Invoice date", d["invoice_date"], "Due date", d["due_date"]]]
   if d.get("po_number"):
       meta_rows.append(["PO number", d["po_number"], "Currency", d["currency_code"]])
   else:
       meta_rows.append(["Currency", d["currency_code"], "", ""])
   meta = Table(meta_rows, colWidths=[1.3 * inch, 2.2 * inch, 1.3 * inch, 2.2 * inch])
   meta.setStyle(TableStyle([
       ("FONTSIZE", (0, 0), (-1, -1), 9),
       ("TEXTCOLOR", (0, 0), (0, -1), colors.HexColor("#2b3a67")),
       ("TEXTCOLOR", (2, 0), (2, -1), colors.HexColor("#2b3a67")),
       ("FONTNAME", (0, 0), (0, -1), "Helvetica-Bold"),
       ("FONTNAME", (2, 0), (2, -1), "Helvetica-Bold"),
       ("BOTTOMPADDING", (0, 0), (-1, -1), 3), ("TOPPADDING", (0, 0), (-1, -1), 3)]))
   story += [meta, Spacer(1, 12)]
  
   bill = [Paragraph("BILL TO", LBL), Paragraph(d["bill_to_name"], BODY),
           Paragraph(d["bill_to_address"], SMALL)]
   if d.get("ship_to_name"):
       ship = [Paragraph("SHIP TO", LBL), Paragraph(d["ship_to_name"], BODY),
               Paragraph(d["ship_to_address"], SMALL)]
   else:
       ship = [Paragraph("SHIP TO", LBL), Paragraph("Same as billing address", SMALL)]
   parties = Table([[bill, ship]], colWidths=[3.5 * inch, 3.5 * inch])
   parties.setStyle(TableStyle([("VALIGN", (0, 0), (-1, -1), "TOP"),
                                ("LEFTPADDING", (0, 0), (-1, -1), 0)]))
   story += [parties, Spacer(1, 14)]
  
   rows = [["Description", "Qty", "Unit price", "Amount"]]
   for (desc, q, up, t) in c["items"]:
       rows.append([desc, str(q), money(up), money(t)])
   items_tbl = Table(rows, colWidths=[3.5 * inch, 0.7 * inch, 1.4 * inch, 1.4 * inch])
   items_tbl.setStyle(TableStyle([
       ("BACKGROUND", (0, 0), (-1, 0), colors.HexColor("#2b3a67")),
       ("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
       ("FONTSIZE", (0, 0), (-1, -1), 9.5),
       ("ALIGN", (1, 0), (-1, -1), "RIGHT"),
       ("GRID", (0, 0), (-1, -1), 0.4, colors.HexColor("#cdd3e6")),
       ("ROWBACKGROUNDS", (0, 1), (-1, -1), [colors.white, colors.HexColor("#eef1f8")]),
       ("LEFTPADDING", (0, 0), (-1, -1), 8), ("TOPPADDING", (0, 0), (-1, -1), 5),
       ("BOTTOMPADDING", (0, 0), (-1, -1), 5)]))
   story += [items_tbl, Spacer(1, 10)]
  
   tot_rows = [["Subtotal", money(c["subtotal"])]]
   if c["discount"]:
       tot_rows.append(["Discount", "-" + money(c["discount"])])
   tot_rows.append([f"Tax ({d['tax_rate']*100:.1f}%)", money(c["tax"])])
   tot_rows.append(["TOTAL", money(c["total"])])
   totals = Table(tot_rows, colWidths=[1.6 * inch, 1.4 * inch], hAlign="RIGHT")
   totals.setStyle(TableStyle([
       ("FONTSIZE", (0, 0), (-1, -1), 10),
       ("ALIGN", (0, 0), (-1, -1), "RIGHT"),
       ("LINEABOVE", (0, -1), (-1, -1), 1.0, colors.HexColor("#2b3a67")),
       ("FONTNAME", (0, -1), (-1, -1), "Helvetica-Bold"),
       ("TEXTCOLOR", (0, -1), (-1, -1), colors.HexColor("#2b3a67")),
       ("TOPPADDING", (0, 0), (-1, -1), 3), ("BOTTOMPADDING", (0, 0), (-1, -1), 3)]))
   story += [totals, Spacer(1, 8)]
  
   pay_rows = [["Amount paid", money(c["amount_paid"])],
               ["Balance due", money(c["balance"])]]
   pay = Table(pay_rows, colWidths=[1.6 * inch, 1.4 * inch], hAlign="RIGHT")
   due_color = colors.HexColor("#1b7a3d") if c["is_paid"] else colors.HexColor("#7a2e2e")
   pay.setStyle(TableStyle([
       ("FONTSIZE", (0, 0), (-1, -1), 10),
       ("ALIGN", (0, 0), (-1, -1), "RIGHT"),
       ("FONTNAME", (0, 1), (-1, 1), "Helvetica-Bold"),
       ("TEXTCOLOR", (0, 1), (-1, 1), due_color),
       ("TOPPADDING", (0, 0), (-1, -1), 2), ("BOTTOMPADDING", (0, 0), (-1, -1), 2)]))
   status = "PAID IN FULL" if c["is_paid"] else "BALANCE DUE"
   story += [pay, Spacer(1, 6),
             Paragraph(f"Status: {status}", BODY), Spacer(1, 16),
             Paragraph("Notes", LBL), Paragraph(d["notes"], BODY)]
   SimpleDocTemplate(path, pagesize=LETTER,
                     topMargin=0.7 * inch, bottomMargin=0.7 * inch,
                     leftMargin=0.8 * inch, rightMargin=0.8 * inch).build(story)
print("STEP 3/7 · Generating synthetic invoice PDFs…")
CORPUS = []
for i, d in enumerate(DOCS):
   path = f"/content/invoice_{i}.pdf" if os.path.isdir("/content") else f"invoice_{i}.pdf"
   render_pdf(d, path)
   CORPUS.append((d, ground_truth(d), path))
   print(f"     ✓ {os.path.basename(path)}  —  {d['vendor_name']} → {d['bill_to_name']}")
print()
if SHOW_FIRST_PAGE:
   try:
       import pypdfium2 as pdfium, matplotlib.pyplot as plt
       pg  = pdfium.PdfDocument(CORPUS[0][2])[0]
       img = pg.render(scale=2.0).to_pil()
       plt.figure(figsize=(6.4, 8.3)); plt.imshow(img); plt.axis("off")
       plt.title("What lift reads — page 1 of invoice_0.pdf", fontsize=10); plt.show()
   except Exception as e:
       print("     page preview skipped:", e, "\n")

Credit: Source link

YOU MAY ALSO LIKE

Rockstar Workers In The UK Will Hold A Union Vote Just As GTA 6 Is Released

Anthropic Finds Analysts Defer to AI Agents in Judgment Study – Unite.AI

ShareTweetSendSharePin

Related Posts

Rockstar Workers In The UK Will Hold A Union Vote Just As GTA 6 Is Released
AI & Technology

Rockstar Workers In The UK Will Hold A Union Vote Just As GTA 6 Is Released

October 27, 2026
Anthropic Finds Analysts Defer to AI Agents in Judgment Study – Unite.AI
AI & Technology

Anthropic Finds Analysts Defer to AI Agents in Judgment Study – Unite.AI

October 27, 2026
This Old Nokia Phone Got An AI Upgrade It Was Never Designed For
AI & Technology

This Old Nokia Phone Got An AI Upgrade It Was Never Designed For

October 27, 2026
Axiom Math Releases 43.1M-Line Lean Proof of Group Classification – Unite.AI
AI & Technology

Axiom Math Releases 43.1M-Line Lean Proof of Group Classification – Unite.AI

October 27, 2026
Next Post
Taylor Swift and Travis Kelce's wedding day arrives with Madison Square Garden under tight security – CBS News

Taylor Swift and Travis Kelce's wedding day arrives with Madison Square Garden under tight security - CBS News

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Wall Street is urging Anthropic, OpenAI to do their IPOs in a hurry — here’s why

Wall Street is urging Anthropic, OpenAI to do their IPOs in a hurry — here’s why

October 23, 2026
Tesla Showcases Long-Awaited Roadster With Aerial Tricks

Tesla Showcases Long-Awaited Roadster With Aerial Tricks

October 21, 2026
Katie Zacharia out as White House press secretary after 5 days on the job

Katie Zacharia out as White House press secretary after 5 days on the job

October 24, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!