if shipped goods - returned goods = 0 AND invoices are all processed resulting in value equals 0 then
SO can be canceled (not deleted)
else
SO can NOT be canceled
if shipped goods - returned goods <> 0 then
message = There are still goods shipped incl. packing numbers
if invoices not processed then
message = There are still draft or open invoices, incl numbers
The idea is that if all goods are returned and all corresponding invoices are processed the sum result is zero for product quantities and purchase or sales amount.
If this is not the case, e.g. shipping fees exist on invoice, the SO can not be canceled and a new SO could be generated.
I can imaging that a possible solution could be;
if shipped goods - returned goods = 0 AND invoices are all processed resulting in value equals 0 then
SO can be canceled (not deleted)
else
SO can NOT be canceled
if shipped goods - returned goods <> 0 then
message = There are still goods shipped incl. packing numbers
if invoices not processed then
message = There are still draft or open invoices, incl numbers
The idea is that if all goods are returned and all corresponding invoices are processed the sum result is zero for product quantities and purchase or sales amount.
If this is not the case, e.g. shipping fees exist on invoice, the SO can not be canceled and a new SO could be generated.