Hi, I was trying to achieve the same thing and did it by implemeting the following hook:
/**
* Sets the status of new invoices to Draft
* @params array $vars [
* source => [adminarea, api, autogen]
* user => (string)
* invoiceid => (int)
* status => (string)
* ]
*/
add_hook('InvoiceCreation', 10, function($vars) {
try {
Capsule::table('tblinvoices')
->where('id', $vars['invoiceid'])
->update(
[
'status' => 'Draft',
]
);
logActivity(sprintf('Invoice %d status automatically set to draft', $vars['invoiceid']), 0);
} catch (\Exception $e) {
logActivity(sprintf('Invoice %d status could not be set to draft', $vars['invoiceid']), 0);
}
});