DocHub
Tax rates, discount codes, timing delays, batch limits, location ordering, and all hardcoded constants

Business Rules & Configuration

Tax and Pricing

Rule Value Notes
Tax rate 15% Applied as “Fee” (covers customs/duty), not sales tax
Tax label in Square "Fee" Percentage-based tax applied to order

Discount Codes

Hardcoded Firestore document IDs in the Discounts collection:

Name Firestore Doc ID Discount %
Utila nimQqh6eXpDFSXrr13bf 10%
Business FQenWCGy5LsBIxriB7Ut 10%
VIP Nbt2Fb9FmukcfTpFCgO3 25%
Church/Missionary qgTEDdWrdd7zswIpAOif 10%
Donations JKQf1tfHFwNJ1C5oV79o 30%
Prepaid NO CHARGE LrP13kFPwbo3bDqRwK2H 100%
Guanaja b9iF0YplydMQyuDmC724 10%
La Ceiba aaAduAXWVHGJy6EGcYf4 10%
SAP Pfrz9innx20wGwTGSDHD 10%
Military/Veteran WYqxwVTjISrNZq9DAQIB 10%
Teguc kOZgVmfP4TRwO0w8YWEo 10%

Special Token IDs

Tokens used for special processing logic in invoice calculations:

Token Purpose
ZNKG7JOEMEGOOEPHYUSMUALP Special item: adds a note to the Square invoice
HKTLXKB2EK36MYC54EG3IA7Z Special charge: aggregated differently in cost calculation
T4FJOGCWII3VGZRDNNTTU4ZD Special charge: aggregated differently in cost calculation
mIQbG4QoDRSHVRGKuFsJ Consolidation fee charge ID (used in handlePackageAddition)

Timing & Delays

Delay Duration Function Purpose
Container creation guard 3 minutes handlePackageStatusChange Skips processing if container was created within 3 min (race condition prevention)
Status change delay 5 seconds handlePackageStatusChange Wait before processing
Invoice status check 10 seconds handleInvoiceCreation / handleInvoiceUpdate Wait before auto-approve check
Container task publish 1 minute onContainerCreated Wait before publishing PubSub
Prepaid report 5 minutes prepaidSendEmail Wait after container creation
Retry base delay 5 minutes Retry queue Base delay between retries
Retry backoff 5 / 10 / 15 min Retry queue Exponential: RETRY_DELAY * attempt
No-password period 10 minutes startNoPasswordPeriod Temp password bypass window

Batch Operation Limits

Operation Limit Function
Load to container 125 packages per batch loadToContainer
Approve/unapprove invoices 450 operations per batch approveInvoices / unapproveInvoices
General Firestore batch 500 operations max Various
Archive batch write 500 operations max batchWrite

Retry Queue Configuration

Parameter Value
Max retry attempts 3
Base delay 5 minutes
Backoff strategy Exponential (5min * attempt)
Storage In-memory (not persistent across cold starts)
On max retries exhausted Sets automaticallySent: 2, maxRetriesReached: true

Concurrency Limits

Function Setting
processInvoiceFromQueue max 3 instances
enqueueInvoiceForProcessing min 1, max 50 instances
updateInvoiceOnPackageStatusChange min 1, max 50 instances
p-limit (container processing) 5 concurrent operations

Estimated Arrival Calculations

Package Status Ship Date Estimated Arrival
received / checkIn Next Monday from last scan date Ship date + 5 days
inTransit Container creation date Container creation + 9 days
Email template Ship date (provided) Ship date + 11 days

Report Lookback Windows

Report Window
Invoice/Package daily checks 8 weeks (56 days)
Daily data report 2 months
Container analysis Last 8 containers
Lost packages Latest container creation - 7 days
Unloaded not checked in 4 weeks

Location Order (XLS Reports)

Packages in loaded-packages spreadsheets are grouped in this order:

  1. Roatan
  2. Utila
  3. La Ceiba
  4. Guanaja
  5. Barbareta
  6. Business
  7. No Location

User Role Mapping

Code Display Label
0 Receiving
1 Check In
2 Unloading
3 Client Pick Up
4 Client

Data Archive Rules

Parameter Value
Archive trigger Every new container creation
Which container is archived 8th-to-last container
Collections copied Containers, Packages (+ child packages), Invoices, User, Items, Clients
Duplicate handling copyWithoutDuplicates skips documents that already exist in archive

Prepaid Client List

21 hardcoded Firestore client document IDs receive automatic prepaid space usage reports when new containers are created. These clients have prepaid shipping accounts and their cubic feet usage is calculated from package dimensions.


Data Quality Check Rules

Invoice Checks

  • Missing: clientID, invoiceDate, status, squareCustomerId, packages array
  • Empty packages array
  • Duplicate packages within same invoice
  • Invalid status values

Package Checks

  • Missing: trackingNumber, status, clientID, logistic
  • Duplicate tracking numbers across packages
  • FedEx tracking numbers exceeding 12 characters
  • Invalid status values

Client Checks

  • Missing: clientID, referenceId, showID, squareCustomerId, location

Container Checks

  • Missing: containerCreatedAt