Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/lerichardv/patolab-platform/llms.txt

Use this file to discover all available pages before exploring further.

PatoLab’s invoicing module is fully integrated into the specimen registration flow — every time a new specimen is created, a fiscal invoice is automatically generated, assigned a sequential number from the active CAI range, rendered to PDF using Browsershot, and stored in the system. Staff can view, filter, edit, and export invoices from the dedicated invoices list page. The module also supports deferred payment via credits and recurring charges via rentals.

Invoice Fields

The Invoice model’s $fillable array covers the complete lifecycle of a billing record. Fields are grouped below by their logical function.

Invoice Identifiers

FieldTypeDescription
full_invoice_numberstringComplete formatted number including CAI prefix (e.g. 001-001-01-00000001)
invoice_numberstringZero-padded sequential portion (e.g. 00000001)
cai_range_idinteger (FK)The CAI range this invoice was issued against
invoice_typestringInvoice classification (standard, rental, etc.)

Parties

FieldTypeDescription
customer_idinteger (FK)The billed customer / patient
specimen_idinteger (FK)The specimen this invoice covers (nullable for group/rental invoices)
rental_idinteger (FK)Rental record, if invoice_type is a rental

Amounts

FieldTypeDescription
quantityintegerNumber of units billed
amountdecimal(2)Unit price
discountdecimal(2)Total discount applied
subtotaldecimal(2)amount × quantity − discount
exempt_amountdecimal(2)Amount exempt from ISV
tax_exempt_amountdecimal(2)ISV-exempt taxable base
taxable_amount_15decimal(2)Base subject to 15% ISV
taxable_amount_18decimal(2)Base subject to 18% ISV
isv_15decimal(2)Calculated 15% ISV
isv_18decimal(2)Calculated 18% ISV
totaldecimal(2)Final amount due
total_paiddecimal(2)Amount already collected
custom_amountdecimal(2)Supplementary charge separate from the base price
custom_amount_reasonstringExplanation for the custom amount
age_discount_typestringthird or fourth (age-based discount category)
age_discount_amountdecimal(2)Value of the age discount

Payment Fields

FieldTypeDescription
payment_typestringcash, credit card, bank transfer, check, or credit
payment_method_datedateDate the payment was received
cash_valuedecimal(2)Amount paid in cash
check_numberstringCheque number
check_valuedecimal(2)Amount on the cheque
card_last_4stringLast 4 digits of the card
card_value_chargeddecimal(2)Amount charged to card
card_authorization_codestringCard terminal authorization code
transfer_bank_idinteger (FK)Bank the wire transfer came from
transfer_valuedecimal(2)Transfer amount
transfer_authorization_codestringBank transfer reference number
credit_payment_idinteger (FK)Linked Credit record when payment_type = credit
proof_of_paymentstringStorage path to the uploaded payment voucher file
invoice_filestringStorage path to the generated invoice PDF

Group Invoicing

FieldTypeDescription
is_groupbooleanTrue when this invoice covers a specimen group
group_idinteger (FK)The SpecimenGroup this invoice belongs to
descriptionstringFree-text description (used for rental invoices)

Payment Types

PatoLab supports five payment types on invoice creation:

Cash

Record the cash_value received. No proof of payment file is required for cash transactions.

Credit Card

Store card_last_4, card_value_charged, and card_authorization_code. A proof-of-payment file (voucher) is required.

Bank Transfer

Link to the source transfer_bank_id and store transfer_value and transfer_authorization_code. A proof-of-payment file is required.

Check

Record check_number and check_value. A proof-of-payment file is required.
A fifth option, Credit, defers payment and creates a linked Credit record. An optional initial partial payment can be collected at registration time using any of the four methods above.

Invoices List

GET /invoices
The invoices index supports the following filters via query parameters:
ParameterDescription
searchSearches by invoice number, customer name, customer RTN/ID, or specimen code
payment_typeFilter by payment method
customer_idFilter by customer
has_credityes or no — filter by credit status
invoice_typeFilter by invoice type
date_from / date_toDate range (YYYY-MM-DD)
sort_fielddate, customer, payment_method, credit, specimen_code, total, total_paid
sort_directionasc or desc
Results are paginated at 10 per page. Date range filters are persisted in per-user cookies (cookie key: date_filter_invoices_user_{id}).

Updating an Invoice

PUT /invoices/{invoice}
Requires invoices.manage permission. On save, the invoice PDF is automatically regenerated unless regenerate_pdf=false is passed. For group invoices, individual group_specimens sub-line updates are also accepted in the same request.

Credits

When a specimen is invoiced with payment_type = credit, a Credit record is created tracking credit_amount, amount_paid, and amount_remaining.
GET /credits
View all outstanding credit balances with filtering and pagination.
POST /credits/{credit}/pay
Record a payment against an open credit balance. Accepts payment method details (same fields as invoice payment) and reduces amount_remaining accordingly.
GET /credits/export
Download all credits as a spreadsheet (CSV or XLSX).

Rentals

Rental invoices represent recurring charges not tied to a specimen.
GET /rentals
View all rental records.
POST /rentals/{rental}/pay
Mark a rental payment as received.

Export

GET /invoices/export
Downloads all invoices matching the current filter set as a CSV or XLSX file. Exported columns include: invoice number, date, customer name, RTN/identity, payment method, specimen code, specimen type, examination, total, total paid, and outstanding balance.
GET /credits/export
Downloads all credits in the same CSV/XLSX format.
Every invoice is tied to an active CAI range (cai_ranges table). The CAI (Código de Autorización de Impresión) is a fiscal control number required by Honduran tax authorities. When the last_used_number on a range reaches end_number, the range is automatically marked exhausted and a new range must be configured before further invoices can be issued. See Sequences & CAI Configuration for setup instructions.

Build docs developers (and LLMs) love