Sequel::Model wrapper over the invoices table. Three responsibilities: - Invoice.build takes form params (client, currency, GEL rate, items array) and returns an unsaved Invoice with a freshly-allocated number, normalized line items, and computed subtotal. - Invoice.allocate_number scans for the highest INV-<year>-NNNN and increments. Single-process deploy means no contention; if that changes this needs a DB-side sequence per year. - Instance methods: paid?, status, total, total_gel for the PDF renderer and the public landing page. Items are stored as JSONB; qty and unit_price are kept as strings on the way in/out so BigDecimal arithmetic stays exact through the JSON round-trip. |
||
|---|---|---|
| .. | ||
| db.rb | ||
| invoice.rb | ||
| mailer.rb | ||
| rate_limit.rb | ||