https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43289

--- Comment #1 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 203588
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203588&action=edit
Bug 43289: Fix TypeError in cashup summary modal when totals are strings

format_price() is only defined on Number.prototype (see
format_price.inc), but the /api/v1/cashups/:id summary endpoint's
grouped and total amounts (out.total, income.total, type.total,
data.summary.total, and the derived cashCollected/actualAmount) can
come back as strings - accountlines/cashup DECIMAL columns are
frequently stringified by the DB layer before JSON encoding. Calling
out.total.format_price() on a string throws
'TypeError: out.total.format_price is not a function', aborting the
rest of the modal's success handler and leaving the cashup summary
partially or fully unrendered.

Wrap every such value in Number(...) before calling format_price().
Also fixed the 'Other payment types collected' filter, which compared
type.total !== 0 with strict inequality - always true when type.total
is a string, so a $0.00 payment type could show a spurious row.

Test plan:
1) Configure more than one payment type in CashupPaymentTypes
2) Complete a cashup with income/payout/refund transactions across
   several payment types, including at least one with a zero total
3) Click the cashup's Summary link
4) Before this patch: browser console shows a TypeError and the modal
   render stops partway through (or a $0.00 payment type row appears)
5) Apply the patch, repeat step 3
6) Modal renders fully and correctly, no console error, no spurious
   zero-amount row

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to