Provided that AIF is set up, all you need to do to push sales invoice while posting it is customizing SalesFormLetter_Invoice.updateNow() (see also printJournal() method):
X++:
boolean updateNow()
{
///
this.postJournal();
// ->
if (custInvoiceJour.canXMLBeSent())
{
custInvoiceJour.sendElectronically(XMLDocPurpose::Original, AifSendMode::Async);
}
// <-
#if.never// #speedtest
if (speedExecute_Sales)
speedExecute_Sales.timing(SpeedSalesTiming::InvoiceEnd,'');
#endif
return true;
}