# Invoice allowances and charges

## Donate to this project

### Development Project Status: Under Discussion

Total cost estimate (ex-Tax):
\$5140
Due date for completion of this stage:
17/12/2012

Currently:

• the only sort of discount available is on a per-product basis
• credits must be handled via a separate transaction
• charges must be entered as products
• percentages must be calculated manually

This projects seeks to add support for Invoice level allowances and charges.

An Invoice allowance is a discount or a credit. A charge might be a postage or freight fee, or a fee for late payment.

Both allowances and charges may be expressed as a percentage amount of the total invoice, or a fixed amount.

When expressed as a percentage amount, the data entry will be as a percentage, but internally the allowance/charge will be stored as a total. This will be automatically be updated when the invoice changes.

An Invoice can have multiple allowances or charges.

#### Calculation Model

To simplify calculations, only a single allowance/charge may be expressed as a percentage.

If there are no percentage allowance/charges, the invoice will be calculated as:

```total = sum(invoice items) + sum(charges) - sum(allowances)
```

If there is a percentage charge PC, the invoice will be calculated as:

``` charge_total = sum(invoice item) + sum(fixed charges)
total = (1 + PC / 100) * charge_total - sum(allowances)
```

If there is a percentage allowance PA, the invoice will be calculated as:

```charge_total = sum(invoice item) + sum(charges)
allowance_total = sum(fixed allowances)
total = charge_total - allowance_total - (PA/100 * (charge_total - allowance_total))
```

If the total is negative, then a validation error will be raised and the invoice cannot be saved.

#### Maximum Allowance

The maximum allowance can be set at the Practice, to restrict allowances as a percentage of the invoice total.

If the sum of the allowances exceed this total, then a validation error will be raised and the invoice cannot be saved.

i.e. for the invoice to be valid:

``` allowance_total / total  <= (maximum_allowance / 100)
```

#### Estimates

Estimates must support allowances and charges; when invoicing an Estimate, these will be applied to the Invoice.

#### Reversals

Allowances and charges must also be reversed when an invoice is reversed, so Customer Credits must also support allowances and charges. Where an Invoice has:

• an allowance, these will be reversed with a charge
• a charge, these will be reversed with an allowance

#### Display

For user entry and display, allowances and charges will appear as separate tabs on the invoice.

By default, the amount of an allowance or charge can be edited. Practices can restrict this behaviour by making the relevant archetype field read-only.

#### Reports

The invoice, credit and estimate report templates will be updated to display charges and allowances before the total.

#### Representation

The allowance/charge item will be represented using a new type named Item, created in Administration|Types.

This will have a:

• name
• type - FIXED or PERCENTAGE
• amount

#### Exclusions

The following are out of the scope of this project:

1. Discounts on charges.

This can instead be done by: