> For the complete documentation index, see [llms.txt](https://kb.maica.com.au/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.maica.com.au/data-imports/importing-historical-invoices.md).

# Importing Historical Invoices

&#x20;If you are transitioning to Maica from another system, chances are that you have existing `Invoice` records that you will want to see in your shiny new system.

The good news is, this is entirely possible, however, there are a few things to be mindful of when completing the process.  Please pay careful attention to the below when importing.

{% hint style="warning" %}
We recommend fully testing and validating your import in a Sandbox **prior** to loading `Invoice` records into Production
{% endhint %}

## Import Import Steps

The list below outlines both the steps and the sequence in which they **must be completed** in order to successfully import your historical `Invoice` records into Maica.

1. Ensure there are **no active or current** `ABA Export` records:
   * `Date` = `TODAY`
   * `Status` = `Processed`
2. Import `Invoice` records
   * Set `Claim Behaviour` = `Do Not Claim`
   * This is to ensure these `Invoice` records, specifically the `Payment Request` records are **not processed** with PRODA
3. Import `Invoice Line Item` records
   * Ensure these are **related** to the parent `Invoice` imported in Step 1
4. Import `Payment Request` records with the following mapping:
   * `Claimed Amount` = `Invoice Line Item`.`Line Total`
   * `Paid Amount` = `Claimed Amount`
   * `Status` = `Paid` (API value = `41`)
   * `NDIS Reference` (set this if you have a value as it is great for traceability)
5. Update `ABA Export` record and set `Status` = `Processed`

## Data Import Mapping - Technical Detail

The table below defines the mapping that **must be used** for `Invoice`, `Invoice Line Item` and `Payment Request` records.

<table><thead><tr><th width="321">Object (API Name)</th><th>Mapping (API Name)</th></tr></thead><tbody><tr><td><code>maica__Invoice__c</code></td><td><code>maica__Claim_Behaviour__c</code> = <code>Do Not Claim</code></td></tr><tr><td><code>maica__Invoice_Line_Item__c</code></td><td>Ensure these are related to the parent <code>Invoice</code></td></tr><tr><td><code>maica__Payment_Request__c</code></td><td><code>maica__Claimed_Amount__c</code> = <code>maica__Invoice_Line_Item__c</code>.<code>maica__Line_Total__c</code></td></tr><tr><td><code>maica__Payment_Request__c</code></td><td><code>maica__Paid_Amount__c</code> = <code>maica__Claimed_Amount__c</code></td></tr><tr><td><code>maica__Payment_Request__c</code></td><td><code>maica__Status__c</code> = <code>Paid</code> (API value = <code>41</code>)</td></tr><tr><td><code>maica__Payment_Request__c</code></td><td><code>maica__NDIS_Reference__c</code> (set this if you have a value as it is great for traceability)</td></tr><tr><td><code>maica__ABA_Export__c</code></td><td><code>maica__Status__c</code> = <code>Processed</code></td></tr></tbody></table>

## ABA Export Considerations

Importing `Payment Request` records with the `Status` set to `Paid` means that they **will be included** in an ABA File.

Given this behaviour, we recommend importing all historical `Payment Request` records into a **dedicated** (i.e.their own) `ABA Export`, to ensure there are **no current** `Payment Request` records allocated to the same `ABA Export`.

To do this, simply check that there are **no ABA Export records** with the following properties:

* `Date` = `TODAY` (the date you are executing the Payment Request load)
* `Status` = `Generated`
  * They must be `Processed`

This essentially means that there are no open, or active, `ABA Export` records and that your imported `Payment Request` records will be assigned to a dedicated `ABA Export`.

Given this, we would recommend loading the `Payment Request` records (as well as the `Invoice` and `Invoice Line Item` records) on a weekend or after hours after you have processed the daily 'real' `ABA Export`.

## Claiming Cycle

We recommend importing historical `Invoices` when there are **no in progress claim cycles**, i.e. `Invoices` with `Payment Requests` that have not been finalised.

If the **BPR Remittance** step has not been completed, please ensure that the **BPR Results file has been processed**.  This is a **mandatory** step.  Essentially, you should wait until the in progress BPR Claim cycle is completed to the point of the Results file being processed in Salesforce.
