1 package SL::Controller::CsvImport::Order;
6 use List::MoreUtils qw(any);
9 use SL::Controller::CsvImport::Helper::Consistency;
11 use SL::DB::OrderItem;
13 use SL::DB::PaymentTerm;
15 use SL::DB::Department;
16 use SL::DB::PriceFactor;
17 use SL::DB::Pricegroup;
23 use parent qw(SL::Controller::CsvImport::BaseMulti);
26 use Rose::Object::MakeMethods::Generic
28 'scalar --get_set_init' => [ qw(settings languages_by parts_by contacts_by departments_by projects_by ct_shiptos_by price_factors_by pricegroups_by) ],
34 $self->class(['SL::DB::Order', 'SL::DB::OrderItem']);
37 sub set_profile_defaults {
40 $self->controller->profile->_set_defaults(
41 order_column => $::locale->text('Order'),
42 item_column => $::locale->text('OrderItem'),
43 max_amount_diff => 0.02,
51 return { map { ( $_ => $self->controller->profile->get($_) ) } qw(order_column item_column max_amount_diff) };
55 sub init_cvar_configs_by {
58 my $item_cvar_configs = SL::DB::Manager::CustomVariableConfig->get_all(where => [ module => 'IC' ]);
59 $item_cvar_configs = [grep { $_->has_flag('editable') } @{ $item_cvar_configs }];
62 $ccb->{class}->{'SL::DB::Order'} = [];
63 $ccb->{class}->{'SL::DB::OrderItem'} = $item_cvar_configs;
64 $ccb->{row_ident}->{$self->_order_column} = [];
65 $ccb->{row_ident}->{$self->_item_column} = $item_cvar_configs;
74 my $profile = $self->SUPER::init_profile;
76 # SUPER::init_profile sets row_ident to the translated class name
77 # overwrite it with the user specified settings
78 foreach my $p (@{ $profile }) {
79 if ($p->{class} eq 'SL::DB::Order') {
80 $p->{row_ident} = $self->_order_column;
82 if ($p->{class} eq 'SL::DB::OrderItem') {
83 $p->{row_ident} = $self->_item_column;
87 foreach my $p (@{ $profile }) {
88 my $prof = $p->{profile};
89 if ($p->{row_ident} eq $self->_order_column) {
91 delete @{$prof}{qw(delivery_customer_id delivery_vendor_id proforma quotation amount netamount)};
93 if ($p->{row_ident} eq $self->_item_column) {
95 delete @{$prof}{qw(trans_id)};
103 sub setup_displayable_columns {
106 $self->SUPER::setup_displayable_columns;
108 $self->add_displayable_columns($self->_order_column,
109 { name => 'datatype', description => $self->_order_column . ' [1]' },
110 { name => 'closed', description => $::locale->text('Closed') },
111 { name => 'currency', description => $::locale->text('Currency') },
112 { name => 'currency_id', description => $::locale->text('Currency (database ID)') },
113 { name => 'cusordnumber', description => $::locale->text('Customer Order Number') },
114 { name => 'delivered', description => $::locale->text('Delivered') },
115 { name => 'delivery_term_id', description => $::locale->text('Delivery terms (database ID)') },
116 { name => 'delivery_term', description => $::locale->text('Delivery terms (name)') },
117 { name => 'employee_id', description => $::locale->text('Employee (database ID)') },
118 { name => 'intnotes', description => $::locale->text('Internal Notes') },
119 { name => 'marge_percent', description => $::locale->text('Margepercent') },
120 { name => 'marge_total', description => $::locale->text('Margetotal') },
121 { name => 'notes', description => $::locale->text('Notes') },
122 { name => 'ordnumber', description => $::locale->text('Order Number') },
123 { name => 'quonumber', description => $::locale->text('Quotation Number') },
124 { name => 'reqdate', description => $::locale->text('Reqdate') },
125 { name => 'salesman_id', description => $::locale->text('Salesman (database ID)') },
126 { name => 'shippingpoint', description => $::locale->text('Shipping Point') },
127 { name => 'shipvia', description => $::locale->text('Ship via') },
128 { name => 'transaction_description', description => $::locale->text('Transaction description') },
129 { name => 'transdate', description => $::locale->text('Order Date') },
130 { name => 'verify_amount', description => $::locale->text('Amount (for verification)') . ' [2]' },
131 { name => 'verify_netamount', description => $::locale->text('Net amount (for verification)') . ' [2]'},
132 { name => 'taxincluded', description => $::locale->text('Tax Included') },
133 { name => 'customer', description => $::locale->text('Customer (name)') },
134 { name => 'customernumber', description => $::locale->text('Customer Number') },
135 { name => 'customer_id', description => $::locale->text('Customer (database ID)') },
136 { name => 'vendor', description => $::locale->text('Vendor (name)') },
137 { name => 'vendornumber', description => $::locale->text('Vendor Number') },
138 { name => 'vendor_id', description => $::locale->text('Vendor (database ID)') },
139 { name => 'language_id', description => $::locale->text('Language (database ID)') },
140 { name => 'language', description => $::locale->text('Language (name)') },
141 { name => 'payment_id', description => $::locale->text('Payment terms (database ID)') },
142 { name => 'payment', description => $::locale->text('Payment terms (name)') },
143 { name => 'taxzone_id', description => $::locale->text('Tax zone (database ID)') },
144 { name => 'taxzone', description => $::locale->text('Tax zone (description)') },
145 { name => 'cp_id', description => $::locale->text('Contact Person (database ID)') },
146 { name => 'contact', description => $::locale->text('Contact Person (name)') },
147 { name => 'department_id', description => $::locale->text('Department (database ID)') },
148 { name => 'department', description => $::locale->text('Department (description)') },
149 { name => 'globalproject_id', description => $::locale->text('Document Project (database ID)') },
150 { name => 'globalprojectnumber', description => $::locale->text('Document Project (number)') },
151 { name => 'globalproject', description => $::locale->text('Document Project (description)') },
152 { name => 'shipto_id', description => $::locale->text('Ship to (database ID)') },
155 $self->add_cvar_columns_to_displayable_columns($self->_item_column);
157 $self->add_displayable_columns($self->_item_column,
158 { name => 'datatype', description => $self->_item_column . ' [1]' },
159 { name => 'cusordnumber', description => $::locale->text('Customer Order Number') },
160 { name => 'description', description => $::locale->text('Description') },
161 { name => 'discount', description => $::locale->text('Discount') },
162 { name => 'lastcost', description => $::locale->text('Lastcost') },
163 { name => 'longdescription', description => $::locale->text('Long Description') },
164 { name => 'marge_percent', description => $::locale->text('Margepercent') },
165 { name => 'marge_total', description => $::locale->text('Margetotal') },
166 { name => 'ordnumber', description => $::locale->text('Order Number') },
167 { name => 'parts_id', description => $::locale->text('Part (database ID)') },
168 { name => 'partnumber', description => $::locale->text('Part Number') },
169 { name => 'position', description => $::locale->text('position') },
170 { name => 'project_id', description => $::locale->text('Project (database ID)') },
171 { name => 'projectnumber', description => $::locale->text('Project (number)') },
172 { name => 'project', description => $::locale->text('Project (description)') },
173 { name => 'price_factor_id', description => $::locale->text('Price factor (database ID)') },
174 { name => 'price_factor', description => $::locale->text('Price factor (name)') },
175 { name => 'pricegroup_id', description => $::locale->text('Price group (database ID)') },
176 { name => 'pricegroup', description => $::locale->text('Price group (name)') },
177 { name => 'qty', description => $::locale->text('Quantity') },
178 { name => 'reqdate', description => $::locale->text('Reqdate') },
179 { name => 'sellprice', description => $::locale->text('Sellprice') },
180 { name => 'serialnumber', description => $::locale->text('Serial No.') },
181 { name => 'subtotal', description => $::locale->text('Subtotal') },
182 { name => 'unit', description => $::locale->text('Unit') },
187 sub init_languages_by {
190 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $self->all_languages } } ) } qw(id description article_code) };
196 my $all_parts = SL::DB::Manager::Part->get_all;
197 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_parts } } ) } qw(id partnumber ean description) };
200 sub init_contacts_by {
203 my $all_contacts = SL::DB::Manager::Contact->get_all;
206 # by customer/vendor id _and_ contact person id
207 $cby->{'cp_cv_id+cp_id'} = { map { ( $_->cp_cv_id . '+' . $_->cp_id => $_ ) } @{ $all_contacts } };
208 # by customer/vendor id _and_ contact person name
209 $cby->{'cp_cv_id+cp_name'} = { map { ( $_->cp_cv_id . '+' . $_->cp_name => $_ ) } @{ $all_contacts } };
214 sub init_departments_by {
217 my $all_departments = SL::DB::Manager::Department->get_all;
218 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_departments } } ) } qw(id description) };
221 sub init_projects_by {
224 my $all_projects = SL::DB::Manager::Project->get_all;
225 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_projects } } ) } qw(id projectnumber description) };
228 sub init_ct_shiptos_by {
231 my $all_ct_shiptos = SL::DB::Manager::Shipto->get_all(query => [module => 'CT']);
234 # by trans_id _and_ shipto_id
235 $sby->{'trans_id+shipto_id'} = { map { ( $_->trans_id . '+' . $_->shipto_id => $_ ) } @{ $all_ct_shiptos } };
240 sub init_price_factors_by {
243 my $all_price_factors = SL::DB::Manager::PriceFactor->get_all;
244 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_price_factors } } ) } qw(id description) };
247 sub init_pricegroups_by {
250 my $all_pricegroups = SL::DB::Manager::Pricegroup->get_all;
251 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
257 $self->controller->track_progress(phase => 'building data', progress => 0);
260 my $num_data = scalar @{ $self->controller->data };
261 foreach my $entry (@{ $self->controller->data }) {
262 $self->controller->track_progress(progress => $i/$num_data * 100) if $i % 100 == 0;
264 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
265 $self->handle_order($entry);
266 } elsif ($entry->{raw_data}->{datatype} eq $self->_item_column && $entry->{object}->can('part')) {
267 $self->handle_item($entry);
269 $self->handle_cvars($entry, sub_module => 'orderitems');
275 $self->add_info_columns($self->_order_column,
276 { header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
277 # Todo: access via ->[0] ok? Better: search first order column and use this
278 $self->add_columns($self->_order_column,
279 map { "${_}_id" } grep { exists $self->controller->data->[0]->{raw_data}->{$_} } qw(payment delivery_term language department globalproject taxzone cp currency));
280 $self->add_columns($self->_order_column, 'globalproject_id') if exists $self->controller->data->[0]->{raw_data}->{globalprojectnumber};
281 $self->add_columns($self->_order_column, 'cp_id') if exists $self->controller->data->[0]->{raw_data}->{contact};
283 $self->add_info_columns($self->_item_column,
284 { header => $::locale->text('Part Number'), method => 'partnumber' });
285 # Todo: access via ->[1] ok? Better: search first item column and use this
286 $self->add_columns($self->_item_column,
287 map { "${_}_id" } grep { exists $self->controller->data->[1]->{raw_data}->{$_} } qw(project price_factor pricegroup));
288 $self->add_columns($self->_item_column, 'project_id') if exists $self->controller->data->[1]->{raw_data}->{projectnumber};
290 $self->add_cvar_raw_data_columns();
292 $self->add_items_to_order();
293 $self->handle_prices_and_taxes();
296 # If order has errors set error for orderitems as well
298 foreach my $entry (@{ $self->controller->data }) {
300 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
301 $order_entry = $entry;
302 } elsif ( defined $order_entry
303 && $entry->{raw_data}->{datatype} eq $self->_item_column
304 && scalar @{ $order_entry->{errors} } > 0 ) {
305 push @{ $entry->{errors} }, $::locale->text('Error: Invalid order for this order item');
312 my ($self, $entry) = @_;
314 my $object = $entry->{object};
317 if (any { $entry->{raw_data}->{$_} } qw(customer customernumber customer_id)) {
318 $self->check_vc($entry, 'customer_id');
319 $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id;
320 } elsif (any { $entry->{raw_data}->{$_} } qw(vendor vendornumber vendor_id)) {
321 $self->check_vc($entry, 'vendor_id');
322 $vc_obj = SL::DB::Vendor->new(id => $object->vendor_id)->load if $object->vendor_id;
324 push @{ $entry->{errors} }, $::locale->text('Error: Customer/vendor missing');
327 $self->check_contact($entry);
328 $self->check_language($entry);
329 $self->check_payment($entry);
330 $self->check_delivery_term($entry);
331 $self->check_department($entry);
332 $self->check_project($entry, global => 1);
333 $self->check_ct_shipto($entry);
334 $self->check_taxzone($entry);
335 $self->check_currency($entry, take_default => 0);
338 # copy from customer if not given
339 foreach (qw(payment_id language_id taxzone_id currency_id)) {
340 $object->$_($vc_obj->$_) unless $object->$_;
344 $self->handle_salesman($entry);
345 $self->handle_employee($entry);
348 # ToDo: salesman by name
349 sub handle_salesman {
350 my ($self, $entry) = @_;
352 my $object = $entry->{object};
354 $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id;
355 $vc_obj = SL::DB::Vendor->new(id => $object->vendor_id)->load if (!$vc_obj && $object->vendor_id);
357 # salesman from customer/vendor or login if not given
358 if (!$object->salesman) {
359 if ($vc_obj && $vc_obj->salesman_id) {
360 $object->salesman(SL::DB::Manager::Employee->find_by(id => $vc_obj->salesman_id));
362 $object->salesman(SL::DB::Manager::Employee->find_by(login => $::myconfig{login}));
367 # ToDo: employee by name
368 sub handle_employee {
369 my ($self, $entry) = @_;
371 my $object = $entry->{object};
373 # employee from login if not given
374 if (!$object->employee_id) {
375 $object->employee_id(SL::DB::Manager::Employee->find_by(login => $::myconfig{login})->id);
380 my ($self, $entry) = @_;
382 my $object = $entry->{object};
384 # Check whether or not language ID is valid.
385 if ($object->language_id && !$self->languages_by->{id}->{ $object->language_id }) {
386 push @{ $entry->{errors} }, $::locale->text('Error: Invalid language');
390 # Map name to ID if given.
391 if (!$object->language_id && $entry->{raw_data}->{language}) {
392 my $language = $self->languages_by->{description}->{ $entry->{raw_data}->{language} }
393 || $self->languages_by->{article_code}->{ $entry->{raw_data}->{language} };
396 push @{ $entry->{errors} }, $::locale->text('Error: Invalid language');
400 $object->language_id($language->id);
403 if ($object->language_id) {
404 $entry->{info_data}->{language} = $self->languages_by->{id}->{ $object->language_id }->description;
411 my ($self, $entry) = @_;
413 my $object = $entry->{object};
414 return unless $self->check_part($entry);
416 my $part_obj = SL::DB::Part->new(id => $object->parts_id)->load;
418 # copy from part if not given
419 $object->description($part_obj->description) unless $object->description;
420 $object->longdescription($part_obj->notes) unless $object->longdescription;
421 $object->unit($part_obj->unit) unless $object->unit;
422 $object->sellprice($part_obj->sellprice) unless defined $object->sellprice;
423 $object->lastcost($part_obj->lastcost) unless defined $object->lastcost;
425 # set to 0 if not given
426 $object->discount(0) unless $object->discount;
427 $object->ship(0) unless $object->ship;
429 $self->check_project($entry, global => 0);
430 $self->check_price_factor($entry);
431 $self->check_pricegroup($entry);
435 my ($self, $entry) = @_;
437 my $object = $entry->{object};
439 # Check whether or not part ID is valid.
440 if ($object->parts_id && !$self->parts_by->{id}->{ $object->parts_id }) {
441 push @{ $entry->{errors} }, $::locale->text('Error: Invalid part');
445 # Map number to ID if given.
446 if (!$object->parts_id && $entry->{raw_data}->{partnumber}) {
447 my $part = $self->parts_by->{partnumber}->{ $entry->{raw_data}->{partnumber} };
449 push @{ $entry->{errors} }, $::locale->text('Error: Invalid part');
453 $object->parts_id($part->id);
456 # Map description to ID if given.
457 if (!$object->parts_id && $entry->{raw_data}->{description}) {
458 my $part = $self->parts_by->{description}->{ $entry->{raw_data}->{description} };
460 push @{ $entry->{errors} }, $::locale->text('Error: Invalid part');
464 $object->parts_id($part->id);
467 if ($object->parts_id) {
468 $entry->{info_data}->{partnumber} = $self->parts_by->{id}->{ $object->parts_id }->partnumber;
470 push @{ $entry->{errors} }, $::locale->text('Error: Part not found');
478 my ($self, $entry) = @_;
480 my $object = $entry->{object};
482 my $cp_cv_id = $object->customer_id || $object->vendor_id;
483 return 0 unless $cp_cv_id;
485 # Check whether or not contact ID is valid.
486 if ($object->cp_id && !$self->contacts_by->{'cp_cv_id+cp_id'}->{ $cp_cv_id . '+' . $object->cp_id }) {
487 push @{ $entry->{errors} }, $::locale->text('Error: Invalid contact');
491 # Map name to ID if given.
492 if (!$object->cp_id && $entry->{raw_data}->{contact}) {
493 my $cp = $self->contacts_by->{'cp_cv_id+cp_name'}->{ $cp_cv_id . '+' . $entry->{raw_data}->{contact} };
495 push @{ $entry->{errors} }, $::locale->text('Error: Invalid contact');
499 $object->cp_id($cp->cp_id);
502 if ($object->cp_id) {
503 $entry->{info_data}->{contact} = $self->contacts_by->{'cp_cv_id+cp_id'}->{ $cp_cv_id . '+' . $object->cp_id }->cp_name;
509 sub check_department {
510 my ($self, $entry) = @_;
512 my $object = $entry->{object};
514 # Check whether or not department ID is valid.
515 if ($object->department_id && !$self->departments_by->{id}->{ $object->department_id }) {
516 push @{ $entry->{errors} }, $::locale->text('Error: Invalid department');
520 # Map description to ID if given.
521 if (!$object->department_id && $entry->{raw_data}->{department}) {
522 my $dep = $self->departments_by->{description}->{ $entry->{raw_data}->{department} };
524 push @{ $entry->{errors} }, $::locale->text('Error: Invalid department');
528 $object->department_id($dep->id);
535 my ($self, $entry, %params) = @_;
537 my $id_column = ($params{global} ? 'global' : '') . 'project_id';
538 my $number_column = ($params{global} ? 'global' : '') . 'projectnumber';
539 my $description_column = ($params{global} ? 'global' : '') . 'project';
541 my $object = $entry->{object};
543 # Check whether or not projetc ID is valid.
544 if ($object->$id_column && !$self->projects_by->{id}->{ $object->$id_column }) {
545 push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
549 # Map number to ID if given.
550 if (!$object->$id_column && $entry->{raw_data}->{$number_column}) {
551 my $proj = $self->projects_by->{projectnumber}->{ $entry->{raw_data}->{$number_column} };
553 push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
557 $object->$id_column($proj->id);
560 # Map description to ID if given.
561 if (!$object->$id_column && $entry->{raw_data}->{$description_column}) {
562 my $proj = $self->projects_by->{description}->{ $entry->{raw_data}->{$description_column} };
564 push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
568 $object->$id_column($proj->id);
574 sub check_ct_shipto {
575 my ($self, $entry) = @_;
577 my $object = $entry->{object};
579 my $trans_id = $object->customer_id || $object->vendor_id;
580 return 0 unless $trans_id;
582 # Check whether or not shipto ID is valid.
583 if ($object->shipto_id && !$self->ct_shiptos_by->{'trans_id+shipto_id'}->{ $trans_id . '+' . $object->shipto_id }) {
584 push @{ $entry->{errors} }, $::locale->text('Error: Invalid shipto');
591 sub check_price_factor {
592 my ($self, $entry) = @_;
594 my $object = $entry->{object};
596 # Check whether or not price_factor ID is valid.
597 if ($object->price_factor_id && !$self->price_factors_by->{id}->{ $object->price_factor_id }) {
598 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price factor');
602 # Map description to ID if given.
603 if (!$object->price_factor_id && $entry->{raw_data}->{price_factor}) {
604 my $price_factor = $self->price_factors_by->{description}->{ $entry->{raw_data}->{price_factor} };
605 if (!$price_factor) {
606 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price factor');
610 $object->price_factor_id($price_factor->id);
616 sub check_pricegroup {
617 my ($self, $entry) = @_;
619 my $object = $entry->{object};
621 # Check whether or not pricegroup ID is valid.
622 if ($object->pricegroup_id && !$self->pricegroups_by->{id}->{ $object->pricegroup_id }) {
623 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
627 # Map pricegroup to ID if given.
628 if (!$object->pricegroup_id && $entry->{raw_data}->{pricegroup}) {
629 my $pricegroup = $self->pricegroups_by->{pricegroup}->{ $entry->{raw_data}->{pricegroup} };
631 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
635 $object->pricegroup_id($pricegroup->id);
641 sub add_items_to_order {
644 # add orderitems to order
647 foreach my $entry (@{ $self->controller->data }) {
648 # search first/next order
649 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
651 # next order entry: add collected orderitems to the previous one
652 if (defined $order_entry) {
653 $order_entry->{object}->orderitems(@orderitems);
657 $order_entry = $entry;
659 } elsif ( defined $order_entry && $entry->{raw_data}->{datatype} eq $self->_item_column ) {
660 # collect orderitems to add to order (if they have no errors)
661 # ( add_orderitems does not work here if we want to call
662 # calculate_prices_and_taxes afterwards ...
663 # so collect orderitems and add them at once )
664 push @orderitems, $entry->{object} if (scalar @{ $entry->{errors} } == 0);
667 # add last collected orderitems to last order
668 $order_entry->{object}->orderitems(@orderitems) if $order_entry;
671 sub handle_prices_and_taxes() {
674 # calculate prices and taxes
675 foreach my $entry (@{ $self->controller->data }) {
676 next if @{ $entry->{errors} };
678 if ($entry->{raw_data}->{datatype} eq $self->_order_column && $entry->{object}->orderitems) {
680 $entry->{object}->calculate_prices_and_taxes;
682 $entry->{info_data}->{calc_amount} = $entry->{object}->amount_as_number;
683 $entry->{info_data}->{calc_netamount} = $entry->{object}->netamount_as_number;
687 # If amounts are given, show calculated amounts as info and given amounts (verify_xxx).
688 # And throw an error if the differences are too big.
689 my @to_verify = ( { column => 'amount',
690 raw_column => 'verify_amount',
691 info_header => 'Calc. Amount',
692 info_method => 'calc_amount',
693 err_msg => 'Amounts differ too much',
695 { column => 'netamount',
696 raw_column => 'verify_netamount',
697 info_header => 'Calc. Net amount',
698 info_method => 'calc_netamount',
699 err_msg => 'Net amounts differ too much',
702 foreach my $tv (@to_verify) {
703 # Todo: access via ->[0] ok? Better: search first order column and use this
704 if (exists $self->controller->data->[0]->{raw_data}->{ $tv->{raw_column} }) {
705 $self->add_raw_data_columns($self->_order_column, $tv->{raw_column});
706 $self->add_info_columns($self->_order_column,
707 { header => $::locale->text($tv->{info_header}), method => $tv->{info_method} });
711 foreach my $entry (@{ $self->controller->data }) {
712 next if @{ $entry->{errors} };
713 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
714 next if !$entry->{raw_data}->{ $tv->{raw_column} };
715 my $parsed_value = $::form->parse_amount(\%::myconfig, $entry->{raw_data}->{ $tv->{raw_column} });
716 if (abs($entry->{object}->${ \$tv->{column} } - $parsed_value) > $self->settings->{'max_amount_diff'}) {
717 push @{ $entry->{errors} }, $::locale->text($tv->{err_msg});
726 my ($self, %params) = @_;
728 # set order number and collect to save
730 foreach my $entry (@{ $self->controller->data }) {
731 next if $entry->{raw_data}->{datatype} ne $self->_order_column;
732 next if @{ $entry->{errors} };
734 if (!$entry->{object}->ordnumber) {
735 my $number = SL::TransNumber->new(type => 'sales_order',
737 $entry->{object}->ordnumber($number->create_unique());
740 push @{ $objects_to_save }, $entry;
743 $self->SUPER::save_objects(data => $objects_to_save);
747 $_[0]->settings->{'order_column'}
751 $_[0]->settings->{'item_column'}