Can't Get Linked Products_Quotes on Invoice Creation

I have an ‘after_save’ Logic Hook in Invoices that exports the invoice to an outside accounting software api. What is strange is that when the invoice is created for the first time, there are no line items in the aos_products_quotes table. But if you edit then save the invoice, the hook can get the line items. It is as if the after_save logic hook for invoices is being run BEFORE the line items are written.

$line_items = $bean->get_linked_beans(‘aos_products_quotes’,‘AOS_Products_Quotes’);

foreach ($line_items as $line_item) {

This loop returns nothing on the initial save but returns the line items on a subsequent Edit > Save.

My guess is that there are two saves. And I do see them now in AOS_Invoice.php. First it has to save the invoice to get the invoice id as the line items need an id to be associated with. Then it saves the line items. Apparently the after_save is called as part of the invoice save function.

I’m stumped on how to get around this.