openimis-be-invoice_py
OpenIMIS backend module for invoices, bills, and payments.
Bill Code Auto-Generation
Bill.code is auto-assigned by a database trigger and sequence when code is NULL or empty. Explicitly supplied codes are preserved.
Default format
BIL-YY-XXXXXXXXXX
YY— two-digit year (e.g.26for 2026)XXXXXXXXXX— zero-padded 10-digit sequence number
Example: BIL-26-0000000042
Custom code patterns
The code format is configurable via ModuleConfiguration (DB or openimis.json):
{
"bill_code_pattern": "CUSTOM-[YYYY][MM]-[SEQ:8]"
}
Available tokens (free positioning):
| Token | Description | Example output |
|---|---|---|
[SEQ:N] |
Zero-padded sequence number, N digits | 00000042 |
[SEQ] |
Sequence number, no padding | 42 |
[YY] |
2-digit year | 26 |
[YYYY] |
4-digit year | 2026 |
[MM] |
2-digit month | 03 |
Pattern examples:
BIL-[YY]-[SEQ:10]→BIL-26-0000000042(default)INV/[YYYY]/[SEQ:6]→INV/2026/000042CUSTOM-[YYYY][MM]-[SEQ:8]→CUSTOM-202603-00000042[SEQ:12]→000000000042
[SEQ] or [SEQ:N] is required (exactly once). All other text is literal.
How it works
| Database | Mechanism |
|---|---|
| PostgreSQL | BEFORE INSERT trigger on tblBill; calls nextval('bill_code_seq') |
| MSSQL | INSTEAD OF INSERT trigger on tblBill; uses NEXT VALUE FOR bill_code_seq |
On first apply, the migration advances the sequence past the current maximum to avoid collisions.
Trigger auto-sync
The MSSQL trigger lists every column explicitly. To keep it in sync with schema and config changes, a trigger sync service runs automatically:
- On startup —
InvoiceConfig.ready()compares the DB trigger against the current model columns and code pattern. Recreates if different. - On config change — A
post_savesignal onModuleConfigurationre-syncs whenbill_code_patternis updated via the API or admin UI. - Manual — Management command for explicit sync without server restart:
python manage.py sync_code_triggers # sync all (bill + benefit)
python manage.py sync_code_triggers --module invoice # sync bill trigger only
python manage.py sync_code_triggers --module payroll # sync benefit trigger only
python manage.py sync_code_triggers --dry-run # show what would change
The sync compares structured components (column set, code pattern expression) rather than raw SQL text, so formatting differences don't cause false updates.
Migration
invoice/migrations/0014_bill_code_sequence.py — uses RunPython with vendor detection. Fails fast on unsupported DB vendors.
To reverse: python manage.py migrate invoice 0013
Bulk creation
BillService.bulk_create_bills() and bulk_create_bill_items() use bulk_create_with_history from django-simple-history for performance with audit trail. After bulk insert, DB-assigned codes are re-fetched and patched into both the in-memory instances and their history records. Queries are chunked to stay under MSSQL's parameter limit.
Metadata
Release files for openimis-be-invoice 1.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openimis_be_invoice-1.12.0.tar.gz | 74.7 kB | Without provenance | Details for openimis_be_invoice-1.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openimis_be_invoice-1.12.0-py3-none-any.whl | Python 3 | none | any | Details for openimis_be_invoice-1.12.0-py3-none-any.whl |
Total release size: 192.2 kB
Release files / openimis_be_invoice-1.12.0.tar.gz
| Download URL | openimis_be_invoice-1.12.0.tar.gz |
|---|---|
| Size | 74.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a27f48c19fce487581bf7573d3ea034fc45442b8d6fa03c62c2fc7f6c57c191
|
|
BLAKE2b-256 checksum How to use checksums |
524eed1d3258c867b9e1921e36fc3adc0f7f3bbbc3e94e166b885a39bae3d28b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.1
|
Release files / openimis_be_invoice-1.12.0-py3-none-any.whl
| Download URL | openimis_be_invoice-1.12.0-py3-none-any.whl |
|---|---|
| Size | 117.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ab82da01d287e0f66147b811eba8fa8887888034daf7b89daec2871faa3469c
|
|
BLAKE2b-256 checksum How to use checksums |
ece6951a91c5e7ffc4c0fa503dfb233560e7306f597af65232f2d41194de817d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.1
|
Security for openimis-be-invoice 1.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.