gutterboy Posted September 4, 2014 Report Posted September 4, 2014 I'm wanting to get their most overdue invoice, don't care about any other invoices, just their most overdue one (cause basically I'm just trying to find out if they have ANY invoices overdue by 'x' amount of time). Currently I am getting this data by doing something like this: $vars = array('client_id' => $blesta_id, 'status' => 'past_due', 'page' => 1, 'order_by' => array('date_due' => 'ASC')); $response = $this->api->get('invoices', 'getList', $vars); if ($response->response()) { // This will be an array of invoices $invoices = $response->response(); // Get timestamp of the invoice that is most overdue - dates are stored in the database as UTC $most_overdue_date = strtotime($invoices[0]->date_due . " UTC"); /* Now check to see if their most overdue invoice is >= to the days passed in */ // Set date to check for.. $date_check = strtotime("-" . $days . " Days"); if ($most_overdue_date <= $date_check) { } } Is there a better method to use other than "getList" - just seems unnecessary to get a whole page of invoices when I only need one. FTR: $this->api points to the Blesta SDK. Quote
Tyson Posted September 4, 2014 Report Posted September 4, 2014 Blesta doesn't have a method to fetch a single result of the 'longest overdue invoice'. The way you're going about it is what you would need to do. Quote
gutterboy Posted September 4, 2014 Author Report Posted September 4, 2014 Blesta doesn't have a method to fetch a single result of the 'longest overdue invoice'. The way you're going about it is what you would need to do. Ok, no worries. Thanks for the response. 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.