SHOWCASE: SMART EXPENSE REPORTING WITH AI

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.

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.