Skip to content

Scan Expense Receipt

Sends an Expense Receipt image to the Expense Receipt Automation and returns the extracted expense information.

The method accepts the following parameters:

  • response_, out parameter of type CLOB, to which the response will be written.
  • image_data_, required parameter of type BLOB to pass the binary image data to the Expense Receipt Analyzer.
  • scheduling_config_id_, optional parameter to specify the Configuration ID from Scheduling Optimization and Machine Learning Configuration to use. If not specified the 'DEFAULT' configuration will be used.
  • response_format_, optional parameter to specify the response format. Possible values are 'XML', 'JSON' and 'IFS_MESSAGE'. If not specified 'IFS_MESSAGE' will be used as the default format.
BEGIN  
   Ml_Util_API.Scan_Expense_Receipt(
      response_             => :response_,   -- Clob parameter to accept response data.
      image_data_           => :image_data_, -- Blob parameter to pass the binary image data.
      scheduling_config_id_ => 'DEFAULT',    -- Configuration ID to use.
      response_format_      => 'XML');       -- Response format ('XML' / 'JSON' / 'IFS_MESSAGE').
END;

For the above call, the response may look as following. The response may vary depending on the IFS Planning & Scheduling Optimization (PSO) version being used.

<ScanResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/RESTfulGateway.ResponseObjects">
  <Entities>
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>currency_code</Id>
      <Probability>0.71</Probability>
      <Value>EUR</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>currency_code</Id>
      <Probability>0.21</Probability>
      <Value>USD</Value>
    </ExtractedEntity>
...
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>expense_code</Id>
      <Probability>0.5293</Probability>
      <Value>Meals</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>expense_code</Id>
      <Probability>0.0988</Probability>
      <Value>Hotel</Value>
    </ExtractedEntity>
...
    <ExtractedEntity>
      <EntityGroupId>Line1</EntityGroupId>
      <Id>expense_code</Id>
      <Probability>0.1644</Probability>
      <Value>Taxi</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Line1</EntityGroupId>
      <Id>expense_code</Id>
      <Probability>0.0741</Probability>
      <Value>Restaurants/Dining with guests</Value>
    </ExtractedEntity>
...
    <ExtractedEntity>
      <EntityGroupId>Line2</EntityGroupId>
      <Id>expense_code</Id>
      <Probability>0.047</Probability>
      <Value>Parking fees</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Line2</EntityGroupId>
      <Id>expense_code</Id>
      <Probability>0.0377</Probability>
      <Value>Other expenses, travel-related</Value>
    </ExtractedEntity>
...
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>expense_text</Id>
      <Probability>1</Probability>
      <Value>Main Street Restaurant 6332 Business Drive Suite 528 Palo Alto California 94301 575-1628095 Fri 04/07/2017 3:57 PM Order ID: #4a59c18f Order Number: 1 Chocolate Chip Cooki Apple Pie 5.00 3.00 Lava Cake 4.00 Sub Total USD$ 12.00 Grand Total: $12.00 Card: XXXXXXXXXXXXO Tip 14.16 2.16</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Line1</EntityGroupId>
      <Id>expense_text</Id>
      <Probability>1</Probability>
      <Value>Chocolate Chip Cooki</Value>
    </ExtractedEntity>
...
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>merchant_address</Id>
      <Probability>0.981</Probability>
      <Value>6332 Business Drive Suite 528 Palo Alto California 94301</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>merchant_name</Id>
      <Probability>0.935</Probability>
      <Value>Main Street Restaurant</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>merchant_phone_number</Id>
      <Probability>0.982</Probability>
      <Value>+15751628095</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>total_amount</Id>
      <Probability>1</Probability>
      <Value>12.00</Value>
    </ExtractedEntity>
    <ExtractedEntity>
      <EntityGroupId>Line1</EntityGroupId>
      <Id>total_amount</Id>
      <Probability>1</Probability>
      <Value>5.00</Value>
    </ExtractedEntity>
...
    <ExtractedEntity>
      <EntityGroupId>Main</EntityGroupId>
      <Id>transaction_date</Id>
      <Probability>0.6</Probability>
      <Value>2017-07-04</Value>
    </ExtractedEntity>
  </Entities>
  <EntityGroups xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>Main</d2p1:string>
    <d2p1:string>Line1</d2p1:string>
    <d2p1:string>Line2</d2p1:string>
  </EntityGroups>
</ScanResponse>

Tip: The IFS Message response format ('IFS_MESSAGE') allows using existing methods in Message_SYS package to handle the response which may be simpler to use in the PL/SQL code than 'XML' or 'JSON'.

For more details about the Expense Receipt Automation please see the PSO Machine Learning Guide and the PSO Interface Guide.