mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-17 18:20:36 -05:00
Math in the amount box
Arithmetic typed into a line's amount (e.g. 300*1.1) is rounded to the nearest penny and sets the rate from the quantity, as a typed amount already did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
2 files changed
+3
-2
No files matched your search
@@ -310,11 +310,12 @@ $(function () {
|
||||
$tbody.on('change', '.qbo-line-taxable', changed);
|
||||
$tbody.on('input', '.qbo-line-description-input', function () { autoGrow(this); });
|
||||
|
||||
// Typing an amount works out the rate from the quantity
|
||||
// Typing an amount (or math, e.g. 300*1.1, rounded to the penny) works out the rate from the quantity
|
||||
$tbody.on('input', '.qbo-line-amount-input', function () {
|
||||
var $row = $(this).closest('tr');
|
||||
var amount = parseNumber($(this).val());
|
||||
if (amount === null || isNaN(amount)) return;
|
||||
if (isMath($(this).val().replace(/[$,\s]/g, ''))) amount = round(amount, 2);
|
||||
var qty = parseNumber($row.find('.qbo-line-qty-input').val());
|
||||
if (qty === null || isNaN(qty) || qty === 0) qty = 1;
|
||||
$row.find('.qbo-line-rate-input').val(plain(amount / qty, 5));
|
||||
|
||||
Reference in new issue
Block a user