Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2714604a

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 2714604a9184071fcb3986ac19056da50e5c4a4a
  • Vorgänger f26083d9
  • Nachfolger db9ec33a

SL::DB::{DeliveryOrder,Invoice}->new_from: custom_variables der Items mit clonen

Behebt #2365 auf eine etwas angenehmere Weise als
5bd7e74db1f425a8bbc43357e949efcc1d4eb135.

Unterschiede anzeigen:

SL/DB/DeliveryOrder.pm
4 4

  
5 5
use Carp;
6 6

  
7
use Rose::DB::Object::Helpers ();
8

  
7 9
use SL::DB::MetaSetup::DeliveryOrder;
8 10
use SL::DB::Manager::DeliveryOrder;
9 11
use SL::DB::Helper::FlattenToForm;
......
81 83
  goto &transdate;
82 84
}
83 85

  
86
sub _clone_orderitem_cvar {
87
  my ($cvar) = @_;
88

  
89
  my $cloned = Rose::DB::Object::Helpers::clone_and_reset($_);
90
  $cloned->sub_module('delivery_order_items');
91

  
92
  return $cloned;
93
}
94

  
84 95
sub new_from {
85 96
  my ($class, $source, %params) = @_;
86 97

  
......
124 135
  my $delivery_order = $class->new(%args, %params);
125 136

  
126 137
  my @items = map {
127
    my $source_item = $_;
138
    my $source_item      = $_;
139
    my @custom_variables = map { _clone_orderitem_cvar($_) } @{ $source_item->custom_variables };
140

  
128 141
    SL::DB::DeliveryOrderItem->new(map({ ( $_ => $source_item->$_ ) }
129
                                   qw(base_qty cusordnumber description discount lastcost longdescription marge_price_factor ordnumber parts_id price_factor price_factor_id
130
                                      project_id qty reqdate sellprice serialnumber transdate unit
131
                                   )));
142
                                         qw(base_qty cusordnumber description discount lastcost longdescription marge_price_factor ordnumber parts_id price_factor price_factor_id
143
                                            project_id qty reqdate sellprice serialnumber transdate unit
144
                                         )),
145
                                   custom_variables => \@custom_variables);
146

  
132 147
  } @{ $source->items_sorted };
133 148

  
134 149
  $delivery_order->items(\@items);
SL/DB/Invoice.pm
8 8
use Carp;
9 9
use List::Util qw(first);
10 10

  
11
use Rose::DB::Object::Helpers ();
12

  
11 13
use SL::DB::MetaSetup::Invoice;
12 14
use SL::DB::Manager::Invoice;
13 15
use SL::DB::Helper::FlattenToForm;
......
111 113
  return $self->paid >= $self->amount;
112 114
}
113 115

  
116
sub _clone_orderitem_delivery_order_item_cvar {
117
  my ($cvar) = @_;
118

  
119
  my $cloned = Rose::DB::Object::Helpers::clone_and_reset($_);
120
  $cloned->sub_module('invoice');
121

  
122
  return $cloned;
123
}
124

  
114 125
sub new_from {
115 126
  my ($class, $source, %params) = @_;
116 127

  
......
152 163
  my $invoice = $class->new(%args, %params);
153 164

  
154 165
  my @items = map {
155
    my $source_item = $_;
166
    my $source_item      = $_;
167
    my @custom_variables = map { _clone_orderitem_delivery_order_item_cvar($_) } @{ $source_item->custom_variables };
168

  
156 169
    SL::DB::InvoiceItem->new(map({ ( $_ => $source_item->$_ ) }
157 170
                                 qw(parts_id description qty sellprice discount project_id serialnumber pricegroup_id ordnumber transdate cusordnumber unit
158 171
                                    base_qty longdescription lastcost price_factor_id), @item_columns),
159
                            deliverydate => $source_item->reqdate,
160
                            fxsellprice  => $source_item->sellprice,);
172
                             deliverydate     => $source_item->reqdate,
173
                             fxsellprice      => $source_item->sellprice,
174
                             custom_variables => \@custom_variables,
175
                           );
176

  
161 177
  } @{ $source->items_sorted };
162 178

  
163 179
  $invoice->invoiceitems(\@items);

Auch abrufbar als: Unified diff