Module: ReceiptsHelper

Defined in:
app/helpers/receipts_helper.rb

Overview

View helpers for the receipts CRM screens.

Instance Method Summary collapse

Instance Method Details

#receipt_detail_balance(detail) ⇒ BigDecimal, ...

Linked-document balance shown in a receipt-detail row's "Balance" column.
Prefers the controller's batch-computed @detail_balances (one grouped
query set for the whole form — see ReceiptFinancials#detail_document_balances) and
falls back to the per-row ReceiptDetail#invoice_balance reader on forms
that don't precompute them (new / new_payment), which render few rows.

Parameters:

Returns:

  • (BigDecimal, Numeric, nil)


13
14
15
16
17
18
19
# File 'app/helpers/receipts_helper.rb', line 13

def receipt_detail_balance(detail)
  if @detail_balances&.key?(detail.id)
    @detail_balances[detail.id]
  else
    detail.invoice_balance
  end
end