• bitcoinBitcoin(BTC)$60,783.003.55%
  • ethereumEthereum(ETH)$1,704.883.55%
  • tetherTether(USDT)$1.000.01%
  • binancecoinBNB(BNB)$552.302.46%
  • usd-coinUSDC(USDC)$1.000.00%
  • rippleXRP(XRP)$0.954.84%
  • solanaSolana(SOL)$70.954.73%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.061.33%
  • tronTRON(TRX)$0.303564-1.27%
  • HyperliquidHyperliquid(HYPE)$61.105.88%
  • zcashZcash(ZEC)$725.052.36%
  • moneroMonero(XMR)$492.78-2.05%
  • dogecoinDogecoin(DOGE)$0.0568466.28%
  • leo-tokenLEO Token(LEO)$8.97-0.47%
  • whitebitWhiteBIT Coin(WBT)$61.4910.16%
  • chainlinkChainlink(LINK)$9.257.40%
  • USDSUSDS(USDS)$1.000.01%
  • cardanoCardano(ADA)$0.1487686.84%
  • Ethena USDeEthena USDe(USDE)$1.000.02%
  • stellarStellar(XLM)$0.1273964.60%
  • daiDai(DAI)$1.000.00%
  • bitcoin-cashBitcoin Cash(BCH)$207.126.46%
  • nearNEAR Protocol(NEAR)$3.0910.18%
  • litecoinLitecoin(LTC)$43.628.89%
  • CantonCanton(CC)$0.0777035.64%
  • avalanche-2Avalanche(AVAX)$6.633.76%
  • tether-goldTether Gold(XAUT)$3,558.101.58%
  • uniswapUniswap(UNI)$4.735.18%
  • USD1USD1(USD1)$1.00-0.02%
  • Ripple USDRipple USD(RLUSD)$1.00-0.01%
  • suiSui(SUI)$0.676.30%
  • the-open-networkGram (prev. Toncoin)(GRAM)$0.963.97%
  • Global DollarGlobal Dollar(USDG)$1.000.01%
  • hedera-hashgraphHedera(HBAR)$0.0536868.81%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.15-0.15%
  • paypal-usdPayPal USD(PYUSD)$1.000.02%
  • quant-networkQuant(QNT)$151.107.81%
  • BittensorBittensor(TAO)$183.505.93%
  • shiba-inuShiba Inu(SHIB)$0.0000045.69%
  • Circle USYCCircle USYC(USYC)$1.150.02%
  • Spiko Amundi Overnight Swap Fund (EUR)Spiko Amundi Overnight Swap Fund (EUR)(EURSAFO)$1.120.37%
  • crypto-com-chainCronos(CRO)$0.0397272.16%
  • MemeCoreMemeCore(M)$0.8512.07%
  • RainRain(RAIN)$0.002554-7.28%
  • okbOKB(OKB)$82.133.63%
  • Falcon USDFalcon USD(USDF)$1.000.07%
  • United StablesUnited Stables(U)$1.000.00%
  • pax-goldPAX Gold(PAXG)$3,557.381.57%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • pepePepe(PEPE)$0.0000045.14%
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

SpaceX Gets FCC Approval To Deploy 1 Million Satellites For Its AI Orbital Data Center

WaterSense Raises €5.75M in Pre-Seed and Grants for AI Water Monitoring – Unite.AI

ShareTweetSendSharePin

Related Posts

SpaceX Gets FCC Approval To Deploy 1 Million Satellites For Its AI Orbital Data Center
AI & Technology

SpaceX Gets FCC Approval To Deploy 1 Million Satellites For Its AI Orbital Data Center

November 26, 2026
WaterSense Raises €5.75M in Pre-Seed and Grants for AI Water Monitoring – Unite.AI
AI & Technology

WaterSense Raises €5.75M in Pre-Seed and Grants for AI Water Monitoring – Unite.AI

November 26, 2026
BharatGen Launches Patram 1.5 with Promptable OCR and Abstention – Unite.AI
AI & Technology

BharatGen Launches Patram 1.5 with Promptable OCR and Abstention – Unite.AI

November 26, 2026
Neuralink Receives FDA Approval For ‘Pivotal’ Brain Implant Trial In ALS Patients
AI & Technology

Neuralink Receives FDA Approval For ‘Pivotal’ Brain Implant Trial In ALS Patients

November 26, 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
When I See A Stock Market Correction Without A Recession, I See A Buying Opportunity (SPY)

When I See A Stock Market Correction Without A Recession, I See A Buying Opportunity (SPY)

November 24, 2026
Dangerous floods wash out regions in Florida

Dangerous floods wash out regions in Florida

November 26, 2026
Timeline: See when the major East Coast Thanksgiving week storm will impact your area – FOX Weather

Timeline: See when the major East Coast Thanksgiving week storm will impact your area – FOX Weather

November 25, 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!