flangefrog Posted April 5, 2014 Report Posted April 5, 2014 I made this mod in response to another thread but I figured it would be best to cross post it here. If that's not allowed then please remove this thread. When you add a payment manually, it will automatically apply the payment to the invoices, oldest first. It will check any invoices with an amount above zero. E.g. if the client has three invoices - $30 and $10, and $20 and paid $37, $30 will be paid to the first invoice and $7 to the second. The third invoice will be unpaid. Note: this doesn't actually add any real functionality to Blesta, it will just make it easier to apply the payments without having to work out manually how much to apply to each invoice. /app/views/admin/default/admin_clients_recordpayment.pdt After line 79 $(document).ready(function() { add: $("#amount").change(function() { amountRemaining = Math.max($(this).val(), 0); if (!isNaN(amountRemaining)) { $("#invoices_to_pay").find("tr").not(".heading_row").each(function() { checkBoxElement = $(this).find("input[name^=\'invoice_id\']"); applyAmountElement = $(this).find("input[name^=\'applyamount\']"); amountDueElement = applyAmountElement.parent().next(); amountDue = Number(amountDueElement.text().substr(1).replace(/[^0-9\.]+/g, "")); applyAmount = Math.min(amountRemaining, amountDue); amountRemaining = (amountRemaining - applyAmount).toFixed(2); applyAmountElement.val(applyAmount); checkBoxElement.prop("checked", applyAmount > 0); if (!amountRemaining) return false; }); } }); If you want the calc to run while typing, change line 80 to: $("#amount").on("input",function() { Just be aware that this is unsupported or buggy on older browsers. apply_payments_calc.xml domaingood, Michael and PauloV 3 Quote
flangefrog Posted June 22, 2014 Author Report Posted June 22, 2014 Made this into a vQmod - See above. LukesUbuntu 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.