fix: pending/paid invoices

This commit is contained in:
Sergei Poljanski 2026-06-08 19:00:03 +03:00
commit 37a491cf79
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
4 changed files with 35 additions and 9 deletions

View file

@ -27,6 +27,17 @@ class Invoice < Sequel::Model(:invoices)
paid? ? 'paid' : 'pending'
end
# Both status variants are pre-rendered at creation; `pdf_key` is the base
# path (no suffix). The download route picks a variant by current status.
def pdf_key_for(status)
base = pdf_key.sub(/\.pdf\z/, '')
"#{base}-#{status}.pdf"
end
def current_pdf_key
pdf_key_for(status)
end
def total
BigDecimal(subtotal.to_s)
end