S/D/Order: before_save-hooks f. indiv. Lieferadressen, um …
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 25 Aug 2020 13:27:49 +0000 (15:27 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Tue, 25 Aug 2020 14:17:06 +0000 (16:17 +0200)
- keine leeren zu speichern
- das Modul immer auf 'OE' zu setzen

SL/DB/Order.pm

index 657252f..af5d803 100644 (file)
@@ -58,6 +58,8 @@ __PACKAGE__->attr_sorted('items');
 
 __PACKAGE__->before_save('_before_save_set_ord_quo_number');
 __PACKAGE__->before_save('_before_save_create_new_project');
+__PACKAGE__->before_save('_before_save_remove_empty_custom_shipto');
+__PACKAGE__->before_save('_before_save_set_custom_shipto_module');
 
 # hooks
 
@@ -98,6 +100,23 @@ sub _before_save_create_new_project {
   return 1;
 }
 
+
+sub _before_save_remove_empty_custom_shipto {
+  my ($self) = @_;
+
+  $self->custom_shipto(undef) if $self->custom_shipto && $self->custom_shipto->is_empty;
+
+  return 1;
+}
+
+sub _before_save_set_custom_shipto_module {
+  my ($self) = @_;
+
+  $self->custom_shipto->module('OE') if $self->custom_shipto;
+
+  return 1;
+}
+
 # methods
 
 sub items { goto &orderitems; }