Richzendy Posted June 11, 2020 Report Share Posted June 11, 2020 Hi all, i'm reading this thread: But don't have replies (and is very old, from 2014) and is something similar about i want, i need to add usable items like calls from a pbx service on a recurrent bills, but can be for example on a hosting company adding the usage charges of bandwidth, how i can manage this? how i can catch the invoice before is created and add extra items? i need to add the call log and add a partial and total price from all calls on the billing period, i see this Event Handler Invoices.add on https://docs.blesta.com/display/dev/Event+Handlers But i don't know how to use and i don't see how to use on the module documentation, i need a plugin? someone have any example? someone are dealing with something similar to this before and have any tip? Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Richzendy Posted September 21, 2020 Author Report Share Posted September 21, 2020 Follow up... this can be done on a module? https://docs.blesta.com/display/dev/Plugin+Events Or is only to plugins? Quote Link to comment Share on other sites More sharing options...
Adam Posted September 22, 2020 Report Share Posted September 22, 2020 From what I understand you want each invoice generated for a customer to be charged on usage. For example, used VoIP minutes in your PBX system or bandwidth used on a hosting plan? I am not as familiar with modules as I am with plugins but from reading the documentation it does not appear you can control the price of a service once it has been established. I don't think modules can subscribe to event notifications. I also do not think modules are involved in the invoice creation process which makes them easy to write, implement and maintain but in your case has some limitations. You are correct in that you can use a plugin to overwrite and add this functionality. You can use any module (universal, existing, custom, etc.) and then with your custom plugin subscribe for every Invoices.add event. At that point, your plugin code could get the invoice, client and package information and then connect with your 3rd party system (PBX, port bandwidth usage, etc.) and update the invoice to include the necessary line items. The one gotcha that might happen with this solution is that your clients *might* get an email with an invoice and PDF of the amount _before_ your plugin finishes. I have not verified this but taking a quick look at the code I think that is the right behavior. Maybe one of the Blesta devs can confirm this. Hope this helps. -Adam Quote Link to comment Share on other sites More sharing options...
Richzendy Posted September 23, 2020 Author Report Share Posted September 23, 2020 Hi, thanks for your response @Adam, Sorry, maybe i don't explain me very well. I don't want to change the service price, i only want to add new items to the bill. Actually the service to my module create a service bill at the end of the billing cycle and i have a cron to run later and this cron create custom invoices to extra charges like calls and DID numbers, but i want to a unique bill to the service with all items to avoid extra fees if the client use a credit card to pay for all, i want a total amount to all items and a unique payment. Quote Link to comment Share on other sites More sharing options...
Adam Posted September 25, 2020 Report Share Posted September 25, 2020 On 9/23/2020 at 12:35 PM, Richzendy said: I don't want to change the service price, i only want to add new items to the bill. Ya, I got that from your first message. My comment regarding invoices and pricing was looking at the API for modules there is no function that delegates invoices or pricing to any module. That is all part of the core components of modules that can not be overwritten. Again, I could not wrong but that is my understanding for things. On 9/23/2020 at 12:35 PM, Richzendy said: Actually the service to my module create a service bill at the end of the billing cycle and i have a cron to run later and this cron create custom invoices to extra charges like calls and DID numbers, but i want to a unique bill to the service with all items to avoid extra fees if the client use a credit card to pay for all, i want a total amount to all items and a unique payment. Yup, that is one way to do it. The other way is what we described above to replace your cronjob via a Blesta plugin. The plugin will listen/subscribe to all Invoices.add events and then determine if the invoice needs to have additional line items added and have the total be updated. Like I previously mentioned, because invoice creation is handled within the core, there is no plugin or module that can modify the behavior. You could modify Blesta core files as an alternative, but I think subscribing to Invoices.add events is the way to go. Perhaps one of the Blesta Staff might have better ideas. Quote Link to comment Share on other sites More sharing options...
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.