lori Posted July 20, 2014 Report Posted July 20, 2014 Hi, When I create an invoice and check the 'send email' box, no email is sent and the invoice is labeled as unsent in client profile. If I check the box for the invoice on the client profile page, and then click 'submit' to email the invoice, the email is sent as it should be. How can I get the email to be sent when the invoice is first created? Thanks. Quote
0 Michael Posted July 20, 2014 Report Posted July 20, 2014 Hi, When I create an invoice and check the 'send email' box, no email is sent and the invoice is labeled as unsent in client profile. If I check the box for the invoice on the client profile page, and then click 'submit' to email the invoice, the email is sent as it should be. How can I get the email to be sent when the invoice is first created? Thanks. It should be sent when the 5 minute cron job runs. Do you have the cron job running? Quote
0 Blesta Addons Posted July 20, 2014 Report Posted July 20, 2014 It should be sent when the 5 minute cron job runs. Do you have the cron job running? Normally if you create invoice manually and the box is checked , the invoice should sent immediatly . PauloV 1 Quote
0 Michael Posted July 20, 2014 Report Posted July 20, 2014 Normally if you create invoice manually and the box is checked , the invoice should sent immediatly . Never has for me, it's unsent then 5 minutes later changes status and in moi inbox Proof 1: http://screencast.com/t/VesCrB7l2 Proof 2: http://screencast.com/t/NTDm9r1FN (19:34-19:35pm) It's only sent immediately if the client places a order and it's accepted. Quote
0 Blesta Addons Posted July 20, 2014 Report Posted July 20, 2014 Never has for me, it's unsent then 5 minutes later changes status and in moi inbox Proof 1: http://screencast.com/t/VesCrB7l2 Proof 2: http://screencast.com/t/NTDm9r1FN (19:34-19:35pm) It's only sent immediately if the client places a order and it's accepted. i have not tested , but i have told is normally should sent it immedialty . i have tried now and is not sent . i think this is a bug , it should sent it immedialty if the creation of invoice was successful . NOTE: Sometimes i ask why some usefull and normal thing was in v 2.5 are dissapeared in the v3 !!! PauloV 1 Quote
0 Michael Posted July 20, 2014 Report Posted July 20, 2014 i have not tested , but i have told is normally should sent it immedialty . i have tried now and is not sent . i think this is a bug , it should sent it immedialty if the creation of invoice was successful . NOTE: Sometimes i ask why some usefull and normal thing was in v 2.5 are dissapeared in the v3 !!! It's not a bug, it's because Blesta 3.x crons run every 5 minutes to do jobs unless a new order comes in which is invoiced straight away but then the pending order activates after payment with the cron jobs, so it's on the 5 minutes time. If you place an order and pay it straight away at 12:06 you have to wait 4 minutes before it's activated. If you order and pay on 12:09 it will be activated in a minute. That's why I put on this on the Account Registration email: If you placed an order for services, you'll receive a separate email once they are activated, please note our crons run every five minutes. Quote
0 Blesta Addons Posted July 20, 2014 Report Posted July 20, 2014 It's not a bug, it's because Blesta 3.x crons run every 5 minutes to do jobs unless a new order comes in which is invoiced straight away but then the pending order activates after payment with the cron jobs, so it's on the 5 minutes time. If you place an order and pay it straight away at 12:06 you have to wait 4 minutes before it's activated. If you order and pay on 12:09 it will be activated in a minute. That's why I put on this on the Account Registration email: If you placed an order for services, you'll receive a separate email once they are activated, please note our crons run every five minutes. but this task i manual task , like creating a service in admin area , so with your logic , if i create service from admin area i should wait until the next cron to activate the service and send the welcome email ?!!!! cron is for automated thing not for manual thing unless i have a option to make it postponed to next time/date , like the cancelation service , if i make a scheduled date then is should be done via cron , but if i cancel the service now it should be canceled now . so why the invoice is not created with the next cron ? and created immediatly ? i beleive this should be changed to sent it immedaitly with invoice creation . PauloV 1 Quote
0 Michael Posted July 20, 2014 Report Posted July 20, 2014 ut this task i manual task , like creating a service in admin area , so with your logic , if i create service from admin area i should wait until the next cron to activate the service and send the welcome email ?!!!! cron is for automated thing not for manual thing unless i have a option to make it postponed to next time/date , like the cancelation service , if i make a scheduled date then is should be done via cron , but if i cancel the service now it should be canceled now . so why the invoice is not created with the next cron ? and created immediatly ? i beleive this should be changed to sent it immedaitly with invoice creation . Yes you will have to wait if you manually do it unless you activate it and not put it in pending, if you tick the box use module, it's sent straight away. If you are doing a invoice on it's own unless you wish to write a email manually it's not going to be sent until the cron runs. Cron is automated yes, and speaking about the manual thing you can do it manually by sending a email yourself, that's manual labour isn't it? Quote
0 lori Posted July 21, 2014 Author Report Posted July 21, 2014 I am still confused as to whether the email should be sent immediately, or on the next cron run when I check the box to email an invoice that was created manually. If the invoice is supposed to be sent at next cron run, then everything is working as it should. I have cron running, but have emailing invoices turned off. Need to keep it that way until I am completely switched from WHMCS to Blesta. If the invoice is supposed to be sent immediately, then it is a bug, or at least is not working for me. Can someone let me know which thing is supposed to happen? If the invoice is meant to be sent at next cron run, I think it would be good if the checkbox message said something like 'Send invoice at next cron run' rather than 'Invoice Delivery: email'. Thanks. Quote
0 Michael Posted July 21, 2014 Report Posted July 21, 2014 I am still confused as to whether the email should be sent immediately, or on the next cron run when I check the box to email an invoice that was created manually. If the invoice is supposed to be sent at next cron run, then everything is working as it should. I have cron running, but have emailing invoices turned off. Need to keep it that way until I am completely switched from WHMCS to Blesta. If the invoice is supposed to be sent immediately, then it is a bug, or at least is not working for me. Can someone let me know which thing is supposed to happen? If the invoice is meant to be sent at next cron run, I think it would be good if the checkbox message said something like 'Send invoice at next cron run' rather than 'Invoice Delivery: email'. Thanks. If you made the invoice manually --> Cron job which runs every 5 minutes to send it depending on the time it was made. If you placed a order from the client side a invoice is created and sent instantly (I believe, the guys at Blesta can enlighten us tomorrow). Quote
0 Blesta Addons Posted July 21, 2014 Report Posted July 21, 2014 I am still confused as to whether the email should be sent immediately, or on the next cron run when I check the box to email an invoice that was created manually. If the invoice is supposed to be sent at next cron run, then everything is working as it should. I have cron running, but have emailing invoices turned off. Need to keep it that way until I am completely switched from WHMCS to Blesta. If the invoice is supposed to be sent immediately, then it is a bug, or at least is not working for me. Can someone let me know which thing is supposed to happen? If the invoice is meant to be sent at next cron run, I think it would be good if the checkbox message said something like 'Send invoice at next cron run' rather than 'Invoice Delivery: email'. Thanks. we are not ttalking about invoices/emails that are generated by system . we are talking about invoice/email generated manually and i have ticked the send email . with your case , no emails is sent , as you have not generated the invoice/email manually , so that mean the system will handle them , if the cron is setup , then it will send it , don't worry you are safe . but in our case the thing is different , i have anticipate to generate invoice and send email , so blesta generate invoice and not sending email until the next cron . i think we have here to option 1 - either blesta change the text label from send email to scheduled email for sending . 2 - make the emails send instantally . PauloV 1 Quote
0 Blesta Addons Posted July 21, 2014 Report Posted July 21, 2014 ..... if you tick the box use module .... we are talking about generating invoice and ticking the invoice delivery . there are no modules here !!! Cron is automated yes, and speaking about the manual thing you can do it manually by sending a email yourself, that's manual labour isn't it? when i tick the box to deliver email is manual labour sir , no ?! i think the probleme here 2 thing 1 - the word or the label should be corrected to be more sense . 2 - blesta has other methode for delivering invoice that is not instantally (paper) , for this i think blesta has this shulded to the cron . but who make sense for me is the email invoice should be sent immediatly if i create it manually and ticked the delivery invoice . Quote
0 Michael Posted July 21, 2014 Report Posted July 21, 2014 we are talking about generating invoice and ticking the invoice delivery . there are no modules here !!! Really? I'm talking about using a module when creating a order! Geez. when i tick the box to deliver email is manual labour sir , no ?! I was being sarcastic... 1 - the word or the label should be corrected to be more sense . 2 - blesta has other methode for delivering invoice that is not instantally (paper) , for this i think blesta has this shulded to the cron . but who make sense for me is the email invoice should be sent immediatly if i create it manually and ticked the delivery invoice . 1. Why? I think you don't understand about server crons... why they are there and what could happen if more than one cron was running at a time.... Shall I tell you? Server CRASH! Fair enough you want a crash and a reboot but most people don't. 2. No it doesn't make sense to run a cron every minute: I'd have a couple of concerns: (1) sometimes a system gets busy and cannot start things exactly on the 30 second point, it is then possible that at the same time you are running one job another job would pop and then you have 2 (or more) jobs doing the same thing. Depending on the script, there may be some significant interference here. Thus, coding in such a script should contain some code to insure that only one instance of the given scripting is running at the same time. (2) The script could possibly have a lot of overhead, and consume more system resources than you might want. This is true if you are competing against a lot of other system activities. Thus as one poster has put it, in this case I'd seriously consider putting in a daemon running with additional processes to ensure it remains running if its of critical importance to your operations. - http://serverfault.com/a/49091 Quote
0 Blesta Addons Posted July 21, 2014 Report Posted July 21, 2014 Really? I'm talking about using a module when creating a order! Geez. Hello Micheal , please ; do not merge between two task (create invoice / create service) . see the first OP post . the thread is talking about invoice delivery in CREATE INVOICE MANUALLY , not related to creating services !!!! (client area , create invoice and not create service) they are two different thing . another time who is manually should be done instantally , who is related to the system is another thing . what is the meaning if i click button now, and the action done after some minutes (less than 5 mi of course) . i should wait the staff to see thier answer . Quote
0 Michael Posted July 21, 2014 Report Posted July 21, 2014 Hello Micheal , please ; do not merge between two task (create invoice / create service) . see the first OP post . the thread is talking about invoice delivery in CREATE INVOICE MANUALLY , not related to creating services !!!! (client area , create invoice and not create service) they are two different thing . another time who is manually should be done instantally , who is related to the system is another thing . what is the meaning if i click button now, and the action done after some minutes (less than 5 mi of course) . i should wait the staff to see thier answer . If you read my replies you would understand clearly what I meant and said. I said the only way it's automated is if the service is created and the module provisioned the service. I also stated that if you created the invoice MANUALLY on it's OWN it will run when the cron runs, which Blesta recommends (and only has options minimum for) 5 minutes. I'm not going to argue with you any more it's just wasting my time when I could be doing better things. Quote
0 Paul Posted July 21, 2014 Report Posted July 21, 2014 Invoices are not immediately sent out via email unless you check the box on a client profile page and click the button to send it. There is an entire invoice delivery system that can send via email, paper, fax, and postal mail. The cron delivers invoices, and by default this occurs every 5 minutes when the cron runs. See Settings > Company > Automation > Deliver Invoices. If you are creating an invoice manually and want to send it right away, uncheck the deliver box, then manually send it after it's created by clicking the checkbox next to the invoice and submitting the form on the client's profile page. Michael 1 Quote
0 lori Posted July 21, 2014 Author Report Posted July 21, 2014 Thanks! I get it now. It is working correctly. Still, I think it would be helpful to re-label the checkbox to send email when an invoice is created manually. In my case, where automatic invoice delivery was turned off, it would have been much clearer if the label gave some kind of suggestion that the email would be scheduled rather than sent immediately. Quote
0 Blesta Addons Posted February 3, 2015 Report Posted February 3, 2015 Is thier a possiblity to change the way of this . When we check send invoice should be sended in the post action not added to the queqe delivery PauloV 1 Quote
0 serge Posted February 3, 2015 Report Posted February 3, 2015 licensecart was saying this here 2. No it doesn't make sense to run a cron every minute: I'd have a couple of concerns: (1) sometimes a system gets busy and cannot start things exactly on the 30 second point, it is then possible that at the same time you are running one job another job would pop and then you have 2 (or more) jobs doing the same thing. Depending on the script, there may be some significant interference here. Thus, coding in such a script should contain some code to insure that only one instance of the given scripting is running at the same time. (2) The script could possibly have a lot of overhead, and consume more system resources than you might want. This is true if you are competing against a lot of other system activities. Thus as one poster has put it, in this case I'd seriously consider putting in a daemon running with additional processes to ensure it remains running if its of critical importance to your operations. - http://serverfault.com/a/49091 I understand we should prevent simultaneous instance of cron, I had to think at this on a custom scrip I done and was not related to Blesta, as I wanted my cron be running every 2 mins, and the way I found to prevent bad effect you was saying was my script start by to create a temporary file in "/var/run/" but it could be in place in current dir path , an this file temporary file having a lock extension, and will be auto-deleted when cron is ended, so when starting running the code check if there is no .lock file.: <?php // START Make sure NOT run more than one instance of this script/file // Reference: http://fr2.php.net/getmypid // create .lock file in this directory: /var/run/YOUR-FILE.lock define('LOCK_FILE', "/var/run/" . basename($argv[0], ".php") . ".lock"); if (!tryLock()) die("Already running.\n"); // quit script if ever runing (locked) # remove the lock when runing the exit function later register_shutdown_function('unlink', LOCK_FILE); # if not locked continue below // HERE YOUR CRON TASKS TO DO sleep(1); // quit this script (with unlock this file as declared above) exit(0); // this function is used very above but declared here, and as exit is just before, it will never be executed "alone" after function tryLock() { # If lock file exists, check if stale. If exists and is not stale, return TRUE # Else, create lock file and return FALSE. if (@symlink("/proc/" . getmypid(), LOCK_FILE) !== FALSE) # the @ in front of 'symlink' is to suppress the NOTICE you get if the LOCK_FILE exists return true; # link already exists # check if it's stale if (is_link(LOCK_FILE) && !is_dir(LOCK_FILE)) { unlink(LOCK_FILE); # try to lock again return tryLock(); } return false; } ?> I would like to get feedback on this idea to apply on Blesta, because I found sending invoice or activate service every 5 mins is in my opinion to long for the world we are living. Example registering a domain name, in my opinion can not wait 5 mins, if it's was me as customers I will found bad a Registry taking 5 mins to register a domain. Quote
0 Paul Posted February 3, 2015 Report Posted February 3, 2015 Invoices are always queued for delivery when created. You can use the invoice email feature to send it right away. Two points on this: Invoices can be delivered via other methods, not just email. Queuing them up for a separate process to deliver them provides consistency. If invoices that should be emailed, are emailed when an invoice is created it will complicate the invoice generation process. The extra time required to email would take invoice generation longer, and introduce more possibility of errors. We want invoice generation to be solid, and stable, and fast. Quote
0 Paul Posted February 3, 2015 Report Posted February 3, 2015 Also, Blesta has its own locking mechanism to prevent race conditions. Quote
0 Tyson Posted February 3, 2015 Report Posted February 3, 2015 I understand we should prevent simultaneous instance of cron, I had to think at this on a custom scrip I done and was not related to Blesta, as I wanted my cron be running every 2 mins, and the way I found to prevent bad effect you was saying was my script start by to create a temporary file in "/var/run/" but it could be in place in current dir path , an this file temporary file having a lock extension, and will be auto-deleted when cron is ended, so when starting running the code check if there is no .lock file.: <?php // START Make sure NOT run more than one instance of this script/file // Reference: http://fr2.php.net/getmypid // create .lock file in this directory: /var/run/YOUR-FILE.lock define('LOCK_FILE', "/var/run/" . basename($argv[0], ".php") . ".lock"); if (!tryLock()) die("Already running.\n"); // quit script if ever runing (locked) # remove the lock when runing the exit function later register_shutdown_function('unlink', LOCK_FILE); # if not locked continue below // HERE YOUR CRON TASKS TO DO sleep(1); // quit this script (with unlock this file as declared above) exit(0); // this function is used very above but declared here, and as exit is just before, it will never be executed "alone" after function tryLock() { # If lock file exists, check if stale. If exists and is not stale, return TRUE # Else, create lock file and return FALSE. if (@symlink("/proc/" . getmypid(), LOCK_FILE) !== FALSE) # the @ in front of 'symlink' is to suppress the NOTICE you get if the LOCK_FILE exists return true; # link already exists # check if it's stale if (is_link(LOCK_FILE) && !is_dir(LOCK_FILE)) { unlink(LOCK_FILE); # try to lock again return tryLock(); } return false; } ?> I would like to get feedback on this idea to apply on Blesta, because I found sending invoice or activate service every 5 mins is in my opinion to long for the world we are living. Example registering a domain name, in my opinion can not wait 5 mins, if it's was me as customers I will found bad a Registry taking 5 mins to register a domain. Cron tasks in Blesta are locked down already to disallow them to be run again when they are currently running. There is no need to write a temp file to perform this check. You may want to look into better implementations of semaphores for your other projects. The 5 minute interval only means that it will take at most 5 minutes for the action to take place (assuming the cron is running normally). You could change this to 1 minute, and then have your cron run every minute, but as you mentioned, that could bring up other issues. serge 1 Quote
0 Blesta Addons Posted February 3, 2015 Report Posted February 3, 2015 If invoices that should be emailed, are emailed when an invoice is created it will complicate the invoice generation process. The extra time required to email would take invoice generation longer, and introduce more possibility of errors. We want invoice generation to be solid, and stable, and fast. i have not understand your attention . normally 1 generate invoice 2 send invoice this is the normal proccess , no ? i'm not talking about batch invoice creation , but the manually proccess of creation from admin side . PauloV 1 Quote
0 Paul Posted February 3, 2015 Report Posted February 3, 2015 i have not understand your attention . normally 1 generate invoice 2 send invoice this is the normal proccess , no ? i'm not talking about batch invoice creation , but the manually proccess of creation from admin side . What you're saying is that when an invoice is manually created, it should work differently than when it's automatically created. I don't like this, because it introduces more complexity into invoice creation, which we want to be as simple as possible. If you think a special case should be made for manually created invoices being delivered immediately if they are set to email, then feel free to open a new feature request thread so we can gauge interest and discuss use cases, and in more detail. Personally I have never had an issue with a little delay in the invoice being sent. It's actually saved me a couple times when I forgot something on the invoice -- a line item, or set the due date incorrectly, etc. In the rare case I want an email to me sent immediately, I uncheck the email box, create the invoice, and then check the box to email it right away to the client on their profile page. Edit: I would actually like an option to "queue" new invoices up for say 15 minutes before they can be delivered. This way, I have a sure-window of 15 minutes (or some other number) where I can make changes to the invoice without worrying about it getting delivered. Michael 1 Quote
0 Blesta Addons Posted February 3, 2015 Report Posted February 3, 2015 If you think a special case should be made for manually created invoices being delivered immediately if they are set to email, then feel free to open a new feature request thread so we can gauge interest and discuss use cases, and in more detail. this is my case , i never complaint about blesta cron for 5minute or more/less , or the qeueq delivery . tonight i will write a feature request with our real case ... PauloV 1 Quote
0 serge Posted February 4, 2015 Report Posted February 4, 2015 Thxs to Tyson about explanation on Cron task Lock in Blesta. Just to share, as my concern was to have a safe 2 mins cron frequency, (my above previous script & lock was not good) I finally found more deadly easy solution using solo, and that work fine on blesta cron: http://timkay.com/solo/ Naturally this beats working with lock/PID files, because an open port is directly tied to a running process, and chances of inconsistency and having to detect and cleanup orphaned PID files, are zero. and regarding 2mins cron frequency VS 5mins recommended by default, I'm not a believers it will consume a lot of resources, if we should avoid using php resources, we should be also afraid when customers load website pages as powered all by php. Solo, need you have Perl installed on your server to create the solo file from console (if you do not have console access ? see my below post):-----------------------------------------------------------------------------------------------------curl -q http://timkay.com/solo/solo -o /usr/local/bin/solo \ && chmod a+x $_ CREATE THE CRONJOB: ------------------------------- open crontab as root in console(if your user is not root just change root to your-user): ------------------------------------------------------------------------------------------- crontab -u root -e Next ad this line in crontab: -------------------------------- */2 * * * * /usr/local/bin/solo -port=5001 php /PATH-TO-BLESTA/index.php cron OR Create the cron job using your server control panel menu N.B.: Depending of your OS, use: */2 * * * * /usr/local/bin/solo -port=5001 php /PATH-TO-BLESTA/index.php cron OR */2 * * * * /usr/local/bin/solo -port=5001 /usr/bin/php /PATH-TO-BLESTA/index.php cron N.B.: ---- As root you can use any available port above 1023. The maximum allowed port number is 65535, but use only one port by cron. In above case, cron frequency is 2 mins. Next, -------- Check in Database Table cron_task_runs table, take note of what are the task_id you want to speed the cron interval.In my case it was task_id : 4, 5, 18 as I want new ordered service when paid, be fast activatedAnd open Table task_id in database, and edit row where task_id & company_id you want to speed interval, & update interval, In my case I have updated all above task_id to interval 2 . (2mins) -------------------------- Ref.: http://kvz.io/blog/2012/12/31/lock-your-cronjobs/ The Flow Can it open your port ? so it's will be starting Blesta cron script Can't open your port?Never mind, Blesta cron script is probably still running, will try again next time Naturally this beats working with lock/PID files, because an open port is directly tied to a running process, and chances of inconsistency and having to detect and cleanup orphaned PID files, are zero. ------------------------ Michael 1 Quote
Question
lori
Hi,
When I create an invoice and check the 'send email' box, no email is sent and the invoice is labeled as unsent in client profile.
If I check the box for the invoice on the client profile page, and then click 'submit' to email the invoice, the email is sent as it should be.
How can I get the email to be sent when the invoice is first created?
Thanks.
27 answers to this question
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.