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.

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...