GrassRanch Billing Export and invoicingProduct · Full-stack · Multi-company · Foreign trade · 2026

Portfolio / Export application

From lot to shipment, with the invoice in order.

GrassRanch's owner runs a group of three companies that export and import South American beef. Every sale ties together a lot with its RENSPA, a container, a health certificate, an export declaration and a commercial invoice the accountant files afterwards. We designed and built an application that organizes that journey per company and leaves a trail for every change.

Client
GrassRanch Meat · a three-company group
Industry
Beef export · Argentina and the United States
Product
Internal, multi-company, bilingual web app
Scope
Product, domain modeling, UX/UI, full-stack, PDF, integrations and operations
Stack
Next.js 15, TypeScript, Drizzle, Neon, Cloudflare R2, Hostinger
Year
2026
Shipments screen with fictitious data: a dotted world map with five routes from the River Plate to Miami, Haifa, Frankfurt, Rotterdam and Shanghai, the air route dashed, and the All, Sea and Air filters.

01The challenge

An export is five documents that must agree.

Selling a container of frozen beef abroad is more than issuing an invoice. The lot has to come from an approved plant and carry a RENSPA, the cargo leaves with a health certificate, travels with a bill of lading and a packing list, and kosher or halal product needs the certificate for that slaughter. The commercial invoice has to say the same thing as all of them.

The group isn't one company, either: it's three legal entities, each with its own identity, bank and customers. The owner wanted one place where each company works without seeing the others, where he sees the whole picture, and where nobody can make up a number that can't be backed later.

What had to line up

  • 01Three companies, each with its issuer and bank
  • 02Importer customers per company
  • 03NAMP/IMPS catalog with NCM and HS codes
  • 04Lots with RENSPA, SENASA plant, slaughter and expiry
  • 05Sea and air shipments
  • 06Health certificates, B/L, export declaration, kosher and halal
  • 07Commercial invoice and annexes
  • 08ARCA filing done by the accountant
  • 09Own prices against the market

Our role

Product and domain modeling, architecture, visual system and interface, frontend and backend development, PDF package generation, price syncing, auditing, testing, decision records and deployment.

02The rule

The decision that shaped the whole system.

If the data doesn't exist, the system won't invent it.

No fake tax authorization code, no assumed market quote, no destination fee filled with a convenient number. An invoice with no tax filing stays a draft; a category with no quote shows its empty state; a shipment with no fee says “no fee configured”. Catalog tariff codes come in as “unverified” until someone confirms them.

Money follows the same idea: amounts are stored as exact decimals, never floats, and an invoice in another currency requires an explicit exchange rate. A dollar price is never converted silently.

Nothing inventedEvery company isolatedEvery change attributedThe accountant files, the system prepares

03Multi-company

Three companies, one owner.

04How a sale moves

From the ranch to the paperwork.

Each step builds on the previous one: the shipment reserves kilos from real lots, documents hang off the shipment, and the invoice takes the ports, vessel and lots it prints on its origin sheet from that shipment.

  1. Lot

    RENSPA · SENASA · slaughter
  2. Shipment

    Sea or air
  3. Trade checklist

    Eight document types
  4. Invoice

    Draft · issued · void
  5. PDF package

    Four sheets
  6. ARCA

    Filed by the accountant
  1. 01

    Lot

    Recorded with product, RENSPA, SENASA plant, slaughter date, expiry and starting kilos. Availability only drops when a shipment reserves it.

  2. 02

    Shipment

    Mode, customer, origin and destination ports, quota, export declaration, dates, vessel, container and seal. Assigning a lot deducts its kilos in the same transaction: two people can't sell the same stock.

  3. 03

    Documents

    Health and origin certificates, B/L, packing list, export declaration, halal, kosher and other. Each with number, issue date, expiry and file; the shipment shows what's missing.

  4. 04

    Invoice

    Issuer, customer, incoterm, payment terms, catalog or free-form lines, freight and insurance, with a live preview. It's saved as a draft and issued from the detail page.

  5. 05

    Package

    On issue, the PDF bundles the invoice, payment instructions, the certificate for each category present, and the shipment's origin and traceability sheet.

  6. 06

    Tax filing

    The accountant files the invoice with ARCA, Argentina's tax agency, outside the app and can then note the voucher number, authorization code and expiry. The system neither requires nor invents them.

The screenshots that follow use fictitious companies, importers, lots, shipments and certificates, created on a local database that was deleted afterwards.

05Shipments and traceability

Where every container is.

06Invoicing

An invoice that holds up.

07The data model

Six decisions you don't see.

44 tables across 27 versioned migrations. Every weighty decision was written down as an ADR —there are 28— so the next person to touch the system knows why it works this way.

01 · Isolation

The company rides on every row.

Customers, products, lots, shipments, invoices and documents carry their company. Line items copy their parent's to filter without joins, and writing to a company other than the active one is rejected on the server.

02 · Stock reservation

One kilo, one sale.

Assigning a lot to a shipment deducts availability inside the same transaction, and a lot can't appear twice in one shipment. In production, Neon's WebSocket pool allows interactive transactions; the HTTP driver doesn't.

03 · Money

Decimals, not floats.

Amounts as decimal strings with integer arithmetic. The live preview and the saved invoice share the same calculation, so their totals match by construction, not by luck.

04 · One view

Screen, email and PDF.

The document renders from a single typed view. The detail page, the email and the PDF don't recompute totals or pick a currency, so they can't contradict each other.

05 · Auditing

Before and after, never deleted.

35 tables have a trigger that stores the old and new values, tied to the operation and its author. The audit tables reject UPDATE, DELETE and TRUNCATE.

06 · Schema in sync

The app migrates itself.

Code and schema drifting apart broke production more than once. The app now applies pending migrations on startup, behind a Postgres lock so two instances don't collide.

08International price

Own prices against the market.

09Where the numbers come from

Quotes with a source and a date.

USDA · daily

Conventional, from report 2453.

A GitHub Actions workflow calls a protected endpoint every day that pulls the Choice cutout from USDA's Datamart, converts dollars per cwt to dollars per kilo and stores the series.

USDA · weekly

Premium, from report 2465.

The Prime grade from the comprehensive report, every Monday. If it fails, only that category degrades; the conventional one stays up.

Europe

ECB and EU carcass price.

Another daily workflow pulls the ECB exchange rate and the European Commission's indicative price, to read the list in EUR per kilo and invoice in euros at the day's rate.

Kosher and halal

Manual, on purpose.

They're slaughter certifications, not quality grades, and nobody publishes their price. They're entered by hand with a source; making up a premium would mean inventing the data.

10Roles and permissions

Seven roles per company.

A user can hold a different role in each company. 7 roles, checked on every page and every server action: hiding a button is never the only barrier.

Super admin

The whole group.

Group view, companies, users, issuers, integrations and the audit log.

Company admin

One entire company.

Runs and configures their company, its access and its document design.

Sales

Customers and quoting.

Importer accounts and invoice preparation.

Billing

Closing invoices.

Issues, voids with a reason and sends invoices.

Logistics

From lot to port.

Lots, shipments, documents and certificates.

Accountant

Read everything, file.

Reads operations, records the ARCA filing and is the one who will connect QuickBooks with their own account.

Viewer

Look, don't change.

Read-only access to the assigned company.

11Audit log

Every change, attributed.

12Bilingual and mobile

In Spanish, in English and on the phone.

13Visual system

A pasture green for a serious tool.

Tom Thumb

Sidebar · Primary action · Headings

HEX
#284030
RGB
40 · 64 · 48
Green 500

Active states · Charts

HEX
#3D5F47
RGB
61 · 95 · 71
Olivine

Accent · Brand on green

HEX
#A1BF75
RGB
161 · 191 · 117
Tower Gray

Market series · Secondary

HEX
#9FBCBF
RGB
159 · 188 · 191
Desert Storm

App background

HEX
#F9F9F7
RGB
249 · 249 · 247
Green 50

Surfaces · Hover

HEX
#F1F5F2
RGB
241 · 245 · 242

14Architecture

Same locally as in production.

The database is picked by its connection URL: Neon in production, PGlite —embedded Postgres— in development and tests. Both support transactions, so the tests exercise the same SQL that runs on the server.

  1. Next.js 15

    App Router · Server Actions
  2. NextAuth

    JWT session · Turnstile
  3. Neon Postgres

    Drizzle · auditing
  4. Cloudflare R2

    Documents and certificates
  5. GitHub Actions

    CI · daily prices
  6. SMTP

    Invoice with its package
  1. 01

    The interface

    Next.js 15.5 with App Router, React 18, strict TypeScript, Tailwind and next-intl. Mutations are Server Actions that first resolve the active company and the permission.

  2. 02

    Access

    NextAuth with credentials and bcrypt, login attempt limiting, Cloudflare Turnstile in production —an incomplete setup rejects sign-in rather than leaving it open— and security headers.

  3. 03

    Documents

    The PDF is generated on the server with Forme and merged with pdf-lib; fonts ship as bundled TTFs. Evidence and certificates go to R2 and are only served to a signed-in user.

  4. 04

    Scheduled work

    Two GitHub Actions workflows sync USDA and European data against token-protected endpoints. CI runs types, lint, tests, build, migration validation, secret scanning, dependency audit and the E2E suite.

  5. 05

    Quality

    More than 490 Vitest tests and 6 Playwright E2E suites on desktop and mobile, against a throwaway database.

There's also a private ChatGPT connector over MCP with OAuth and a per-company QuickBooks foundation. The former only switches on with an identity provider configured; QuickBooks isn't connected.

15Evidence of depth

Technical scope, not a sales result.

Figures counted on the repository. They describe the size of what was built, not sales, kilos exported or hours saved.

44
tables across 27 versioned migrations
35
tables with before-and-after auditing
7
per-company roles, checked on the server
490+
automated tests
28
documented architecture decisions
72
commits from August to October 2026

16Where it stands

Deployed, documented and with clear open items.

The first commit is from 9 August 2026 and the last one reviewed from 18 October. Invoicing, master data, traceability, documents, certificates, document design, reference prices, multi-company, auditing and both languages are built, tested and deployed on Hostinger with the database on Neon.

Electronic invoicing was left out at the owner's request: the group doesn't run it from the system. The accountant files with ARCA and records the result if they want to; the AFIP adapter stays in the code, unused, for a future phase. QuickBooks has its per-company structure but no ledger connected, and the GrassRanch website isn't integrated with the app.

Out of scope or pending

  • 01Automatic e-invoicing (CAE)
  • 02A live QuickBooks connection
  • 03Integration with the website
  • 04Real certificates per company
  • 05Fixing the lot list

17The outcome

What changes when everything agrees.

An invoice you can back line by line.

The group has one place where each company puts its exports together without mixing with the others: the lot with its RENSPA, the container on the map, certificates with their expiry and an invoice that prints exactly what the paperwork says.

And when someone asks who changed a value, when and why, the answer is already written down.

TraceableIsolatedAudited

beleafdesign

Do your invoices say the same thing as your export paperwork?

We design custom systems for operations with their own rules: several companies, documents that expire and numbers that have to hold up. Let's look at how your business runs today.

Let's talk about your project