# Invoice Generation Flow Logic

Maica Client Care can automatically generate Invoices upon the completion of Appointments as per the flow shown below.

{% hint style="info" %}
For each **Appointment Service** for each Participant within an Appointment, **Maica Client Care** generates an associated **Delivery Activity** to capture the service, date, time, and participant having received the **Appointment Service**. It is these Delivery Activity that Maica Client Care's invoice generation flow uses to generate **Invoices** and **Invoice Line Items**.
{% endhint %}

<figure><img src="https://documents.lucid.app/documents/2f1fa9a4-b614-4ae0-bd4a-9dcee4bbd513/pages/O.j-6XMskR9r?a=10590&#x26;x=245&#x26;y=52&#x26;w=774&#x26;h=1061&#x26;store=1&#x26;accept=image%2F*&#x26;auth=LCA%205b15a4fd04bf9bcdbaf6c667aa26ddded8921210d56098daca100da85095d5d6-ts%3D1687644976" alt=""><figcaption><p>Maica Client Care Invoice Generation Flow</p></figcaption></figure>

The following logic applies to each claim type as specified on the [Delivery Activity](https://kb.maica.com.au/client-care-reference-data/delivery-activities).

<table><thead><tr><th width="228">Caim Type</th><th>Maica Action Description</th></tr></thead><tbody><tr><td>Provider Travel</td><td>When <code>Provider Travel</code> has been selected as the claim type for a given Delivery Activity, <strong>Maica Client Care</strong> will check the <code>Chargable Travel Cap</code> setting and ensure that only the maximum allowable amount can be charged.<br><br><em>This calculation is done based on the Quantity on the Invoice when compared with the allowable kms from the Setting.</em></td></tr><tr><td>Cancellation</td><td>When <code>Short Notice Cancellation</code> has been selected as the claim type for a given Delivery Activity, <strong>Maica Client Care</strong> will check the <code>Short Notice Cancellation Period</code> setting and ensure that the delivery activity falls within the configured tolerance.<br><br><em>For example, if the</em> Short Notice Cancellation Period is set to 4 days and the delivery activity date is within 4 days or less, <strong>Maica Client Care</strong> will include this in the invoice. Where the tolerance has been exceeded, <strong>Maica Client Care</strong> will not include this in the invoice.</td></tr><tr><td>Ratios</td><td>Maica Client Care supports ratios, which are set on the Appointment management screen for participants and resources. The following calculation logic applies:<br><br>(<code>Number of Resources</code> * <code>Unit Cost of Service</code>)/<code>Number of Participants</code></td></tr><tr><td>All Others</td><td>All other claim types are automatically included in the invoice as generated following the completion of the Appointment.</td></tr></tbody></table>

### Checking for existing Invoice

As the invoice generation flow runs, it will check for an existing invoice within the period of invoicing, for example `weekly` will result in a weekly invoice to be generated. If an existing invoice has been found, **Maica Client Care** will add invoice line items to this invoice. Where an invoice is not found (for example, at the beginning of the invoice period), **Maica Client Care** will generate an invoice.

{% hint style="info" %}
This generation flow can be amended (or disabled) to implement your required logic using standard Salesforce [Flow](https://help.salesforce.com/s/articleView?id=sf.flow.htm\&language=en_US\&type=5) configuration.
{% endhint %}
