4D Blog

Home Tips Showcase: Smart Expense Reporting With AI

Showcase: Smart Expense Reporting With AI

August 6, 2025

Tips

You know the pain of expense reporting — not for you, for your users. The receipts piling up, the manual entry, the typos that slip through. With 4D AIKit, that grind is gone. A simple upload turns a paper receipt or invoice into clean, structured JSON, ready for your database.

No more wasted time on totals, dates, or vendor names. Vision AI reads it, language models structure it, and 4D ties it straight into your app. From paper to database in seconds — and your users never feel the friction.

HDI AIKit Expense Reporting

With just a few lines of code, you can turn a photo of a paper receipt into a structured, ready-to-store JSON object — no manual entry, no human error.

Example: Extracting Structured Data from a Receipt

Imagine your user uploading a receipt through your application. With AIKit, the system can automatically detect:

  • Document type (receipt, invoice, or purchase order)
  • Date
  • Vendor name
  • Invoice number if available
  • Currency
  • Totals (including and excluding tax)
  • Tax amounts

All this information is parsed into a clean JSON object, ready to be stored in your database.

Code Example:

Here’s what that looks like in practice:

var $client := cs.AIKit.OpenAI.new("YourAPIKey") 

// CONVERT THE IMAGE TO BASE64 IF IT'S NOT A URL 
var $blob := $pictureEntity.picture 
var $base64Encoded : Text 
BASE64 ENCODE($blob; $base64Encoded) 
var $picture := "data:image/jpeg;base64," + $base64Encoded 

var $prompt := "You are an expert assistant in processing accounting documents. Analyze the image of the attached document (receipt, invoice, or purchase order). Return only a JSON object, without any explanation, without markdown tags, without commentary, and without any line break before or after. The JSON must be clean and follow this exact structure: { \"document_type\": \"receipt\" ' \"invoice\" ' \"purchase_order\", \"date\": \"MM-DD-YYYY\", \"vendor\": \"Merchant or company name\", \"invoice_number\": \"text or null\", \"currency\": \"EUR\" ' \"USD\" ' \"other\", \"total_incl_tax\": float or null, \"total_excl_tax\": float or null, \"tax\": float or null, \"items\": [ { \"name\": \"string\", \"quantity\": number or null, \"unit_price\": float or null, \"total_price\": float or null } ] } Remember: no sentences, tags, or text should surround or precede the JSON. Just the pure JSON object, that’s all." 

var $result := $client.chat.vision.create($picture).prompt($prompt).choice.message.content 

var $parsedJSON : Object 
$parsedJSON := JSON Parse($result) 

return $parsedJSON

Benefits: From Paper to Database in Seconds

This solution is ideal for:

  • Employees submitting expense reports quickly and easily
  • Finance teams aiming to reduce manual entry and errors
  • Mobile apps offering document scanning and automation features

No more typing totals, dates, or vendor names — AIKit does the heavy lifting.

Why This Matters

This feature combines the best of three worlds:

  • Vision AI: to read and interpret printed documents.
  • Language Models: to intelligently extract structured data.
  • 4D Integration: to seamlessly connect it all with your application logic and database.

Try It Yourself

All you need is:

  • An image input (camera, scanner, or upload).
  • A valid OpenAI API key.
  • The 4D AIKit component in your project.

Then let the AI handle the rest : clean, structured, and production-ready.

Coming Next…

And this is just the beginning. We’ll be sharing more business-focused use cases with AIKit in upcoming posts. If you already have a scenario in mind, we’d love to hear it — it might even be featured in a future post.

Discuss

Tags 20 R10, 21, 4D AIKit, AI, Artificial Intelligence, Component, OpenAI

Latest related posts

  • March 27, 2026

    AI Coding with 4D and VS Code: A Practical Guide

  • September 15, 2025

    Find the right spot in your 4D Write Pro document with AI

  • September 2, 2025

    Intelligent 4D Write Pro document analysis with AI

David Azancot
David Azancot
– 4D for iOS Product Owner – David Azancot joined the 4D Product team as a Product Owner in 2017. He is responsible for writing user stories and translating them into functional specifications. His role also includes ensuring that feature implementations meet customer needs. David holds an MBA in Marketing, Internet, and Mobility from the Institut Léonard de Vinci. He began his career in 2011 at a mobile startup that was later acquired by Madvertise (a mobile marketing group). Passionate about mobile interfaces, he was a natural choice to develop interactive mobile ad formats for the group in 2015. In parallel, David has been developing his own iOS and Android applications since 2012.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • AI
  • Release infos
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy