mirror of
https://github.com/inventree/inventree-docs.git
synced 2025-04-27 21:26:43 +00:00
Report maths (#448)
* Rename file * Expand conditional example * Add documentation for using media variables
This commit is contained in:
parent
21e3c0fd3e
commit
2b8590eb5d
@ -1,14 +1,8 @@
|
||||
---
|
||||
title: Using media files
|
||||
title: Helper Functions
|
||||
---
|
||||
|
||||
## Media Files
|
||||
|
||||
*Media files* are any files uploaded to the InvenTree server by the user. These are stored under the `/media/` directory and can be accessed for use in custom reports or labels.
|
||||
|
||||
**Load Report Functions**
|
||||
|
||||
To load images into the reports/labels the report helper functions must first be loaded in the template:
|
||||
Some common functions are provided for use in custom report and label templates. To include these, load the `report` functions at the start of the template:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
@ -17,6 +11,40 @@ To load images into the reports/labels the report helper functions must first be
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Maths Operations
|
||||
|
||||
Simple mathematical operators are available, as demonstrated in the example template below:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
<!-- Load the report helper functions -->
|
||||
{% load report %}
|
||||
|
||||
{% add 1 3 %} <!-- Add two numbers together -->
|
||||
{% subtract 4 3 %} <!-- Subtract 3 from 4 -->
|
||||
{% multiply 1.2 3.4 %} <!-- Multiply two numbers -->
|
||||
{% divide 10 2 %} <!-- Divide 10 by 2 -->
|
||||
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
These operators can also be used with variables:
|
||||
|
||||
```html
|
||||
{% raw %}
|
||||
{% load report %}
|
||||
|
||||
{% for line in order.lines %}
|
||||
Total: {% multiply line.purchase_price line.quantity %}<br>
|
||||
{% endfor %}
|
||||
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Media Files
|
||||
|
||||
*Media files* are any files uploaded to the InvenTree server by the user. These are stored under the `/media/` directory and can be accessed for use in custom reports or labels.
|
||||
|
||||
### Uploaded Images
|
||||
|
||||
You can access an uploaded image file if you know the *path* of the image, relative to the top-level `/media/` directory. To load the image into a report, use the `{% raw %}{% uploaded_image ... %}{% endraw %}` tag:
|
@ -106,7 +106,7 @@ Refer to the [barcode documentation](./barcodes.md).
|
||||
|
||||
### Using media files
|
||||
|
||||
Refer to the [media files documentation](./media.md).
|
||||
Refer to the [media files documentation](./helpers.md#media-files).
|
||||
|
||||
### Conditional Formatting
|
||||
|
||||
|
@ -60,6 +60,10 @@ The django template system allows for conditional rendering, providing condition
|
||||
{% raw %}
|
||||
{% if <condition> %}
|
||||
{% do_something %}
|
||||
{% elif <other_condition> %}
|
||||
<!-- something else -->
|
||||
{% else %}
|
||||
<!-- finally -->
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
@ -118,7 +118,7 @@ nav:
|
||||
- Sales Order: report/sales_order.md
|
||||
- BOM: report/bom.md
|
||||
- Labels: report/labels.md
|
||||
- Media Files: report/media.md
|
||||
- Helper Functions: report/helpers.md
|
||||
- Barcodes: report/barcodes.md
|
||||
- Context Variables: report/context_variables.md
|
||||
- Admin:
|
||||
|
Loading…
x
Reference in New Issue
Block a user