Is it possible to make the total automatically calculated when entering the quantity and price of the product or service on the invoice, so that it is not necessary to press the SAVE button to calculate the total?
well, you need to do a little bit of Ajax during the entering of those prices.
So when you enter a price, thereâs an ajax call that calculates the price for you and then returns it to the frontend.
Maybe a better way is to bind CTRL+S to the save button.
Something similar to this:
Instead of finding the ESC key, you need to find the CTRL and the S key.
But hey, maybe youâll find the way to do that Ajax call.
Contributions are open, Pull-requests are welcome
In this app they find solution with js. You can see in invoice.php class calculate and in scripts.js code for calculation. If you know hoe to do it, maybe this can halp you and help us
invoice.php (18.5 KB)
scripts.js.php (27.4 KB)
I renamed the js file to .php so I could attach it.
Great, if you can implement it into InvoicePlane, just make a pull-request and Iâll take a look at it
Haha, thatâs the point, I donât know hit to do it
Step 1 is to fork the github repository to your own âuser spaceâ within github.
Letâs say you did that, youâll now have https://github.com/KuzaJack2021/invoiceplane
Step 2 is to clone your own invoiceplane repository
git clone https://github.com/KuzaJack2021/invoiceplane
youâre now in the development
branch of invoiceplane
. The point is to create a new branch and add your code.
git checkout -b feature/add-ajax-to-invoice-calculation
(something like that)
Youâre now in your own personal branch on your own personal repository. Whatever youâll add you wonât break anything.
Step 3:
Add your code. The invoices
module is located in /application/modules/invoices
and the âAjax Controllerâ is in /application/modules/invoices/controllers
That piece of javascript you posted will go to this controller, to a specific function
The views are located in /application/modules/invoices/views
, that piece of javascript will go in 1 of these views
So ⌠add javascript and adjust the example javascript to something that matches the page.
The âtargetâ is a function within the âajax controllerâ
Youâll find examples on this same view page, since the âsaveâ button also executes an ajax action.
So for example: your javascript will go to a function ârecalculateâ within the AjaxController
Then make sure your javascript will target that function within that controller. Check all those examples on that page.
After that test your results.
If youâre happy with the results, just tell us and weâll do the next steps.