diff --git a/README.md b/README.md index fdb4f43..a63b34e 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Estimates and invoices keep their number, date, customer, total and **man-hours* * **New estimate** from the customer page: Create Estimate opens the Redmine editor. The customer page no longer links to QuickBooks' estimate or payment screens; the customer's name still opens their QuickBooks account page as a fallback. * **Edit** any estimate from the Edit link next to it on the customer page or the issue page. -* **Keyboard entry**: in a line's product box, Tab picks the product the text points to (an exact name, the only match, or the only name starting with it, e.g. "lab" → Labor) and fills the line. Tabbing into the description, quantity or rate selects it, so typing replaces it. The quantity and rate boxes take simple math (e.g. `33*1.3`, `(120+15)/2`; `+ - * /`, `x` for times, parentheses), worked out when you leave the box; math in the rate is rounded to the nearest penny. +* **Keyboard entry**: in a line's product box, Tab picks the product the text points to (an exact name, the only match, or the only name starting with it, e.g. "lab" → Labor) and fills the line. Tabbing into the description, quantity or rate selects it, so typing replaces it. The quantity, rate and amount boxes take simple math (e.g. `33*1.3`, `(120+15)/2`; `+ - * /`, `x` for times, parentheses), worked out when you leave the box; math in the rate or amount is rounded to the nearest penny, and an amount sets the rate from the quantity. * **Duplicate** an estimate to start a similar one: same customer, lines, subtotals, custom fields and messages, dated today, with the current user as sales person. * **Read-only once linked to an issue**: an estimate that an issue is linked to can be viewed, emailed and duplicated, but not changed, so the work doesn't drift from what was quoted. The list shows a View link for these instead of Edit. * **Read-only once billed**: an estimate that's Converted or Closed in QuickBooks, or linked to an invoice, can't be changed here either (including redmine_qbo_lineitems' estimates once they're invoiced). Its page lists the invoices it's on; it can still be viewed, emailed and duplicated, and it shows View instead of Edit in lists. diff --git a/app/views/qbo_estimates/_script.html.erb b/app/views/qbo_estimates/_script.html.erb index b9b35f5..42e2a4f 100644 --- a/app/views/qbo_estimates/_script.html.erb +++ b/app/views/qbo_estimates/_script.html.erb @@ -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));