Invoices
Supplier, invoice number, dates, amounts, payment terms and order references, plus charge rows that take their section from the table caption.
SAMPLE INVOICE Supplier: Bright Steps Learning Co. Address: 48 Maple Avenue, Riverton, RV 20514 Invoice: INV-20241220-014 Issued: 2024-12-20 Services covered: 2024-12-02 through 2024-12-13 Due date: 2025-01-19 Amount payable: USD 3,900.00 Tutoring School Rate Hours Amount Lincoln High USD 25/hour 48 USD 1,200.00 Oak Middle USD 25/hour 36 USD 900.00 Administration School Weekly rate Weeks Amount Lincoln High USD 450/week 2 USD 900.00 Oak Middle USD 450/week 2 USD 900.00 Order reference: PO-552190 Task order: TO-30418 Contract: CN-77215
invoices.ymlspec
# Invoices: the facts an invoice states about itself, each a label and its value, and the rows of its # tables of charges. Slash dates are not read, because their day and month order is not stated. $imports: 'values' $flags: [ CASE_INSENSITIVE ] Invoice: $local: # Between a label and its value: a colon, a number sign, both, or a space. Is: '[ \t]*#?[ \t]*:[ \t]*|[ \t]*#[ \t]*|[ \t]+' # Up to the end of the line. Name: '\S([^\r\n]*\S)?' # A document number: INV-20241219-001, 2025-0042, RE-24/118, 4500123987. Code: $flags: [ -CASE_INSENSITIVE ] $patterns: '[A-Za-z]*[-/]?\d[A-Za-z0-9]*([-/.][A-Za-z0-9]+)*' Till: '[ \t]+(through|thru|to|until|till)[ \t]+|[ \t]*[-–—][ \t]*' Supplier: $local: Label: [ 'Supplier', 'Vendor', 'Seller', 'Contractor', 'From', 'Billed by', '(Service )?provider' ] $fields: { name: Name } # Only after a colon: 'services from 2025-01-01' names no supplier. $patterns: '${Label}[ \t]*:[ \t]*#{name}' $value: '#{name}' Address: $local: Label: [ 'Address', '(Supplier|Remit to|Billing) address' ] $fields: { address: Name } $patterns: '${Label}[ \t]*:[ \t]*#{address}' $value: '#{address}' Id: $local: Label: [ 'Invoice', 'Invoice (number|no\.?|id)', 'Inv\. no\.?' ] $fields: { code: Code } $patterns: '${Label}${Is}#{code}' $value: '#{code}' # A date the invoice states: each kind declares its label. Dates: $flags: [ MULTILINE ] $fields: { date: Date } $patterns: '${Label}${Is}#{date}' $value: '#{date}' Issue: $local: # A bare 'Date' counts only at the start of a line, not in 'Due date' or 'Order date'. Label: [ 'Issued( on)?', 'Issue date', 'Date of issue', 'Invoice date', 'Dated', '^[ \t]*Date' ] Due: $local: Label: [ 'Due date', '(Payment )?due( on| by)?', 'Pay by' ] ServicePeriod: $local: Label: - 'Services covered' - 'Services( rendered| provided| performed)?' - '(Service|Billing|Invoice) period' - 'Period( of service)?' - 'For the period' $fields: { start: Date, end: Date } $patterns: '${Label}${Is}(from[ \t]+)?#{start}${Till}#{end}' $value: { start: '#{start}', end: '#{end}' } # An amount the invoice states: each kind declares its label. Amounts: $fields: { amount: Money::Amount } $patterns: '${Label}${Is}#{amount}' $value: { amount: '#{amount.amount}', currency: '#{amount.currency}' } Subtotal: $local: Label: [ 'Sub-?total' ] Tax: $local: # Sales tax, VAT 20%, Tax (8%) Label: [ '((Sales )?tax|VAT|GST)( \(?\d+(\.\d+)?%\)?)?' ] Payable: $local: Label: - 'Amount (payable|due)' - 'Total( amount)? (payable|due)' - 'Balance due' - 'Please pay' - '(Grand|Invoice) total' - 'Total' # When payment is due, counted in days: Net 30, payable within 30 days. PaymentTerms: $local: { Days: '\d+' } $fields: { days: Days } $patterns: - 'Net ?#{days}' - '(payable |due )?(within|in) #{days} days' $value: '#{days}' # A reference to another document: each kind declares its label. Reference: $fields: { code: Code } $patterns: '${Label}${Is}#{code}' $value: '#{code}' Order: $local: Label: - '(Purchase )?order( reference| ref\.?| number| no\.?)?' - 'P\.?O\.?( number| no\.?)?' TaskOrder: $local: Label: 'Task order( number| no\.?)?' Contract: $local: Label: - 'Contract( reference| ref\.?| number| no\.?)?' - 'Agreement( number| no\.?)?' Other: $local: Label: '((Our|Your|Customer) )?(reference|ref\.?)( number| no\.?)?' # One row of a table of charges. The header names the columns, and a caption above the header, such as # 'Tutoring', names the section of every row. LineItem: $local: Text: '\S([^\r\n]*\S)?' DescriptionHeader: [ 'Description', 'Item', 'Service', 'Product', 'Particulars', 'Details', 'Activity', 'School' ] QuantityHeader: [ 'Qty\.?', 'Quantity', 'Hours', 'Days', 'Weeks', 'Months', 'Units' ] RateHeader: [ 'Rate', '(Hourly|Daily|Weekly|Monthly) rate', 'Unit price', 'Price', 'Unit cost' ] AmountHeader: [ 'Amount', 'Total', 'Line total' ] $fields: section: Text description: Text quantity: Number rate: Money amount: Money::Amount $tables: $caption: section $columns: description: DescriptionHeader quantity: QuantityHeader rate: RateHeader amount: AmountHeader $value: section: '[#{section}]' description: '#{description}' quantity: '[#{quantity}]' rate: '[#{rate.amount}]' per: '[#{rate.per}]' amount: '[#{amount.amount}]' currency: '[#{amount.currency}]'
$ texomy parse input.txt -m invoicesAbout this spec
Invoices: supplier, invoice number, dates, service period, amounts, payment terms and references to orders and contracts, and the rows of charge tables with their section, quantity, rate and amount.
Package files
invoices.ymltexomy.jsonvalues.ymlsamples/consulting.txtsamples/prose.txtsamples/quote.txtsamples/software.txttests/invoices.test.ymltests/samples.test.yml
99 nodes from 14 top-level matches.
Run it yourself
Save the example from Studio to a folder, then in that folder:
texomy parse input.txt -m invoicestexomy testMore examples
Bank statements
Account, period and balance summary, and transactions read from a table whose Debit and Credit columns give each amount its sign.
Education
Student, identifier, institution and print date in any order, and each term with its courses, grades, credit hours and totals.
Logistics
Bills of lading: references, vehicles, sender and receiver with addresses, cargo lines with count, kind and mass, and the totals, in whatever order the document states them.
Resumes
Candidate name, headline and contacts, each job and degree with its own dates, courses, and skills grouped under their area.
Addresses
Address blocks and one-line addresses: recipient, street or post office box with building, suite or mail stop, city, state, postal code and country.
Insurance claims
Explanation of Benefits tables: each claim line with service dates, description, status and every amount in its own field, the totals line as a type of its own, and the remark codes explained below.
Write the spec once. Run it on everything.
Install the CLI, connect your agent, and turn your first sample into typed data in minutes.
brew install texomy/tap/texomy