Jump to content

Recommended Posts

Posted

when a invoice is edit, the Edit() function Delete existing unsent invoice delivery methods. so if we add/edit only the public note or private note the delivery method is not filled again . sample case

Create invoice with email delivery, try edit the invoice via model (plugin/api) in the same time (before the cron run, a better way is a event to test it on the fly), then the email delivery will be removed an no delivery is set again !! so the invoice will not send until we send it manually . i can't tell is a real bug, but is a bad behavior of editing the invoice via model, i think it should be marked in the docs to include the delivery var with the data set in edit.

something i think is similar to a previous behavior we have discovery with the invoice status, when we want to edit only a note or a lines, we should always send the status of the invoice to not be converted to active invoice when we use proforma .

 

Posted

we will put a sample fix, so in our case we need to made something like that, in case anyone try to use the event triggers for invoice.add, all invoices edited  with the event Invoices.Add will end with no delivery method set .

// preserve the actual status
$vars['status'] = $invoice->status;
// Preserve the delivery method (in case of unsent invoice)
if (!empty($invoice->delivery)) {
	foreach ($invoice->delivery as $key => $value) {
		$vars['delivery'][] = ['method' => $value];
	}
}
$this->Invoices->edit($invoice->id, $vars);

 

Posted

Yes, you'll need to provide the unsent delivery methods if you would like them to be maintained. The use of models will be updated in the future to provide better and more succinct actions for updates like these.

Posted
  On 5/8/2018 at 6:48 PM, Tyson said:

Yes, you'll need to provide the unsent delivery methods if you would like them to be maintained. The use of models will be updated in the future to provide better and more succinct actions for updates like these.

Expand  

this is only affecting the unset invoice .

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...