asxpio/lib
Sergei Poljanski 1220f37d5f
invoicing: Invoice model with number allocation and totals
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.
2026-05-26 17:43:28 +03:00
..
db.rb db: connection helper and invoices migration 2026-05-26 17:43:18 +03:00
invoice.rb invoicing: Invoice model with number allocation and totals 2026-05-26 17:43:28 +03:00
mailer.rb useful icon and links 2026-05-05 00:57:11 +04:00
rate_limit.rb ruby rework with contact form 2026-05-05 00:45:27 +04:00