Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

  • 2 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...