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 taxzones_by price_factors_by pricegroups_by) ],
34 $self->class(['SL::DB::Order', 'SL::DB::OrderItem']);
41 return { map { ( $_ => $self->controller->profile->get($_) ) } qw(order_column item_column max_amount_diff) };
45 sub init_cvar_configs_by {
48 my $item_cvar_configs = SL::DB::Manager::CustomVariableConfig->get_all(where => [ module => 'IC' ]);
49 $item_cvar_configs = [grep { $_->has_flag('editable') } @{ $item_cvar_configs }];
52 $ccb->{class}->{'SL::DB::Order'} = [];
53 $ccb->{class}->{'SL::DB::OrderItem'} = $item_cvar_configs;
54 $ccb->{row_ident}->{$self->_order_column} = [];
55 $ccb->{row_ident}->{$self->_item_column} = $item_cvar_configs;
64 my $profile = $self->SUPER::init_profile;
66 # SUPER::init_profile sets row_ident to the translated class name
67 # overwrite it with the user specified settings
68 foreach my $p (@{ $profile }) {
69 if ($p->{class} eq 'SL::DB::Order') {
70 $p->{row_ident} = $self->_order_column;
72 if ($p->{class} eq 'SL::DB::OrderItem') {
73 $p->{row_ident} = $self->_item_column;
77 foreach my $p (@{ $profile }) {
78 my $prof = $p->{profile};
79 if ($p->{row_ident} eq $self->_order_column) {
81 delete @{$prof}{qw(delivery_customer_id delivery_vendor_id proforma quotation amount netamount)};
83 if ($p->{row_ident} eq $self->_item_column) {
85 delete @{$prof}{qw(trans_id)};
93 sub setup_displayable_columns {
96 $self->SUPER::setup_displayable_columns;
98 $self->add_displayable_columns($self->_order_column,
99 { name => 'datatype', description => $self->_order_column . ' [1]' },
100 { name => 'closed', description => $::locale->text('Closed') },
101 { name => 'currency', description => $::locale->text('Currency') },
102 { name => 'currency_id', description => $::locale->text('Currency (database ID)') },
103 { name => 'cusordnumber', description => $::locale->text('Customer Order Number') },
104 { name => 'delivered', description => $::locale->text('Delivered') },
105 { name => 'delivery_term_id', description => $::locale->text('Delivery terms (database ID)') },
106 { name => 'delivery_term', description => $::locale->text('Delivery terms (name)') },
107 { name => 'employee_id', description => $::locale->text('Employee (database ID)') },
108 { name => 'intnotes', description => $::locale->text('Internal Notes') },
109 { name => 'marge_percent', description => $::locale->text('Margepercent') },
110 { name => 'marge_total', description => $::locale->text('Margetotal') },
111 { name => 'notes', description => $::locale->text('Notes') },
112 { name => 'ordnumber', description => $::locale->text('Order Number') },
113 { name => 'quonumber', description => $::locale->text('Quotation Number') },
114 { name => 'reqdate', description => $::locale->text('Reqdate') },
115 { name => 'salesman_id', description => $::locale->text('Salesman (database ID)') },
116 { name => 'shippingpoint', description => $::locale->text('Shipping Point') },
117 { name => 'shipvia', description => $::locale->text('Ship via') },
118 { name => 'transaction_description', description => $::locale->text('Transaction description') },
119 { name => 'transdate', description => $::locale->text('Order Date') },
120 { name => 'verify_amount', description => $::locale->text('Amount (for verification)') . ' [2]' },
121 { name => 'verify_netamount', description => $::locale->text('Net amount (for verification)') . ' [2]'},
122 { name => 'taxincluded', description => $::locale->text('Tax Included') },
123 { name => 'customer', description => $::locale->text('Customer (name)') },
124 { name => 'customernumber', description => $::locale->text('Customer Number') },
125 { name => 'customer_id', description => $::locale->text('Customer (database ID)') },
126 { name => 'vendor', description => $::locale->text('Vendor (name)') },
127 { name => 'vendornumber', description => $::locale->text('Vendor Number') },
128 { name => 'vendor_id', description => $::locale->text('Vendor (database ID)') },
129 { name => 'language_id', description => $::locale->text('Language (database ID)') },
130 { name => 'language', description => $::locale->text('Language (name)') },
131 { name => 'payment_id', description => $::locale->text('Payment terms (database ID)') },
132 { name => 'payment', description => $::locale->text('Payment terms (name)') },
133 { name => 'taxzone_id', description => $::locale->text('Tax zone (database ID)') },
134 { name => 'taxzone', description => $::locale->text('Tax zone (description)') },
135 { name => 'cp_id', description => $::locale->text('Contact Person (database ID)') },
136 { name => 'contact', description => $::locale->text('Contact Person (name)') },
137 { name => 'department_id', description => $::locale->text('Department (database ID)') },
138 { name => 'department', description => $::locale->text('Department (description)') },
139 { name => 'globalproject_id', description => $::locale->text('Document Project (database ID)') },
140 { name => 'globalprojectnumber', description => $::locale->text('Document Project (number)') },
141 { name => 'globalproject', description => $::locale->text('Document Project (description)') },
142 { name => 'shipto_id', description => $::locale->text('Ship to (database ID)') },
145 $self->add_cvar_columns_to_displayable_columns($self->_item_column);
147 $self->add_displayable_columns($self->_item_column,
148 { name => 'datatype', description => $self->_item_column . ' [1]' },
149 { name => 'cusordnumber', description => $::locale->text('Customer Order Number') },
150 { name => 'description', description => $::locale->text('Description') },
151 { name => 'discount', description => $::locale->text('Discount') },
152 { name => 'lastcost', description => $::locale->text('Lastcost') },
153 { name => 'longdescription', description => $::locale->text('Long Description') },
154 { name => 'marge_percent', description => $::locale->text('Margepercent') },
155 { name => 'marge_total', description => $::locale->text('Margetotal') },
156 { name => 'ordnumber', description => $::locale->text('Order Number') },
157 { name => 'parts_id', description => $::locale->text('Part (database ID)') },
158 { name => 'partnumber', description => $::locale->text('Part Number') },
159 { name => 'project_id', description => $::locale->text('Project (database ID)') },
160 { name => 'projectnumber', description => $::locale->text('Project (number)') },
161 { name => 'project', description => $::locale->text('Project (description)') },
162 { name => 'price_factor_id', description => $::locale->text('Price factor (database ID)') },
163 { name => 'price_factor', description => $::locale->text('Price factor (name)') },
164 { name => 'pricegroup_id', description => $::locale->text('Price group (database ID)') },
165 { name => 'pricegroup', description => $::locale->text('Price group (name)') },
166 { name => 'qty', description => $::locale->text('Quantity') },
167 { name => 'reqdate', description => $::locale->text('Reqdate') },
168 { name => 'sellprice', description => $::locale->text('Sellprice') },
169 { name => 'serialnumber', description => $::locale->text('Serial No.') },
170 { name => 'subtotal', description => $::locale->text('Subtotal') },
171 { name => 'unit', description => $::locale->text('Unit') },
176 sub init_languages_by {
179 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $self->all_languages } } ) } qw(id description article_code) };
185 my $all_parts = SL::DB::Manager::Part->get_all;
186 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_parts } } ) } qw(id partnumber ean description) };
189 sub init_contacts_by {
192 my $all_contacts = SL::DB::Manager::Contact->get_all;
195 # by customer/vendor id _and_ contact person id
196 $cby->{'cp_cv_id+cp_id'} = { map { ( $_->cp_cv_id . '+' . $_->cp_id => $_ ) } @{ $all_contacts } };
197 # by customer/vendor id _and_ contact person name
198 $cby->{'cp_cv_id+cp_name'} = { map { ( $_->cp_cv_id . '+' . $_->cp_name => $_ ) } @{ $all_contacts } };
203 sub init_departments_by {
206 my $all_departments = SL::DB::Manager::Department->get_all;
207 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_departments } } ) } qw(id description) };
210 sub init_projects_by {
213 my $all_projects = SL::DB::Manager::Project->get_all;
214 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_projects } } ) } qw(id projectnumber description) };
217 sub init_ct_shiptos_by {
220 my $all_ct_shiptos = SL::DB::Manager::Shipto->get_all(query => [module => 'CT']);
223 # by trans_id _and_ shipto_id
224 $sby->{'trans_id+shipto_id'} = { map { ( $_->trans_id . '+' . $_->shipto_id => $_ ) } @{ $all_ct_shiptos } };
229 sub init_taxzones_by {
232 my $all_taxzones = SL::DB::Manager::TaxZone->get_all;
233 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_taxzones } } ) } qw(id description) };
236 sub init_price_factors_by {
239 my $all_price_factors = SL::DB::Manager::PriceFactor->get_all;
240 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_price_factors } } ) } qw(id description) };
243 sub init_pricegroups_by {
246 my $all_pricegroups = SL::DB::Manager::Pricegroup->get_all;
247 return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
253 $self->controller->track_progress(phase => 'building data', progress => 0);
256 my $num_data = scalar @{ $self->controller->data };
257 foreach my $entry (@{ $self->controller->data }) {
258 $self->controller->track_progress(progress => $i/$num_data * 100) if $i % 100 == 0;
260 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
261 $self->handle_order($entry);
262 } elsif ($entry->{raw_data}->{datatype} eq $self->_item_column && $entry->{object}->can('part')) {
263 $self->handle_item($entry);
265 $self->handle_cvars($entry, sub_module => 'orderitems');
271 $self->add_info_columns($self->_order_column,
272 { header => $::locale->text('Customer/Vendor'), method => 'vc_name' });
273 # Todo: access via ->[0] ok? Better: search first order column and use this
274 $self->add_columns($self->_order_column,
275 map { "${_}_id" } grep { exists $self->controller->data->[0]->{raw_data}->{$_} } qw(payment delivery_term language department globalproject taxzone cp currency));
276 $self->add_columns($self->_order_column, 'globalproject_id') if exists $self->controller->data->[0]->{raw_data}->{globalprojectnumber};
277 $self->add_columns($self->_order_column, 'cp_id') if exists $self->controller->data->[0]->{raw_data}->{contact};
279 $self->add_info_columns($self->_item_column,
280 { header => $::locale->text('Part Number'), method => 'partnumber' });
281 # Todo: access via ->[1] ok? Better: search first item column and use this
282 $self->add_columns($self->_item_column,
283 map { "${_}_id" } grep { exists $self->controller->data->[1]->{raw_data}->{$_} } qw(project price_factor pricegroup));
284 $self->add_columns($self->_item_column, 'project_id') if exists $self->controller->data->[1]->{raw_data}->{projectnumber};
286 $self->add_cvar_raw_data_columns();
288 $self->add_items_to_order();
289 $self->handle_prices_and_taxes();
292 # If order has errors set error for orderitems as well
294 foreach my $entry (@{ $self->controller->data }) {
296 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
297 $order_entry = $entry;
298 } elsif ( defined $order_entry
299 && $entry->{raw_data}->{datatype} eq $self->_item_column
300 && scalar @{ $order_entry->{errors} } > 0 ) {
301 push @{ $entry->{errors} }, $::locale->text('Error: Invalid order for this order item');
308 my ($self, $entry) = @_;
310 my $object = $entry->{object};
313 if (any { $entry->{raw_data}->{$_} } qw(customer customernumber customer_id)) {
314 $self->check_vc($entry, 'customer_id');
315 $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id;
316 } elsif (any { $entry->{raw_data}->{$_} } qw(vendor vendornumber vendor_id)) {
317 $self->check_vc($entry, 'vendor_id');
318 $vc_obj = SL::DB::Vendor->new(id => $object->vendor_id)->load if $object->vendor_id;
320 push @{ $entry->{errors} }, $::locale->text('Error: Customer/vendor missing');
323 $self->check_contact($entry);
324 $self->check_language($entry);
325 $self->check_payment($entry);
326 $self->check_delivery_term($entry);
327 $self->check_department($entry);
328 $self->check_project($entry, global => 1);
329 $self->check_ct_shipto($entry);
330 $self->check_taxzone($entry);
331 $self->check_currency($entry, take_default => 0);
334 # copy from customer if not given
335 foreach (qw(payment_id language_id taxzone_id currency_id)) {
336 $object->$_($vc_obj->$_) unless $object->$_;
340 $self->handle_salesman($entry);
341 $self->handle_employee($entry);
344 # ToDo: salesman by name
345 sub handle_salesman {
346 my ($self, $entry) = @_;
348 my $object = $entry->{object};
349 my $vc_obj = SL::DB::Customer->new(id => $object->customer_id)->load if $object->customer_id;
350 $vc_obj = SL::DB::Vendor->new(id => $object->vendor_id)->load if (!$vc_obj && $object->vendor_id);
352 # salesman from customer/vendor or login if not given
353 if (!$object->salesman) {
354 if ($vc_obj && $vc_obj->salesman_id) {
355 $object->salesman(SL::DB::Manager::Employee->find_by(id => $vc_obj->salesman_id));
357 $object->salesman(SL::DB::Manager::Employee->find_by(login => $::myconfig{login}));
362 # ToDo: employee by name
363 sub handle_employee {
364 my ($self, $entry) = @_;
366 my $object = $entry->{object};
368 # employee from login if not given
369 if (!$object->employee_id) {
370 $object->employee_id(SL::DB::Manager::Employee->find_by(login => $::myconfig{login})->id);
375 my ($self, $entry) = @_;
377 my $object = $entry->{object};
379 # Check whether or not language ID is valid.
380 if ($object->language_id && !$self->languages_by->{id}->{ $object->language_id }) {
381 push @{ $entry->{errors} }, $::locale->text('Error: Invalid language');
385 # Map name to ID if given.
386 if (!$object->language_id && $entry->{raw_data}->{language}) {
387 my $language = $self->languages_by->{description}->{ $entry->{raw_data}->{language} }
388 || $self->languages_by->{article_code}->{ $entry->{raw_data}->{language} };
391 push @{ $entry->{errors} }, $::locale->text('Error: Invalid language');
395 $object->language_id($language->id);
398 if ($object->language_id) {
399 $entry->{info_data}->{language} = $self->languages_by->{id}->{ $object->language_id }->description;
406 my ($self, $entry) = @_;
408 my $object = $entry->{object};
409 return unless $self->check_part($entry);
411 my $part_obj = SL::DB::Part->new(id => $object->parts_id)->load;
413 # copy from part if not given
414 $object->description($part_obj->description) unless $object->description;
415 $object->longdescription($part_obj->notes) unless $object->longdescription;
416 $object->unit($part_obj->unit) unless $object->unit;
417 $object->sellprice($part_obj->sellprice) unless defined $object->sellprice;
418 $object->lastcost($part_obj->lastcost) unless defined $object->lastcost;
420 # set to 0 if not given
421 $object->discount(0) unless $object->discount;
422 $object->ship(0) unless $object->ship;
424 $self->check_project($entry, global => 0);
425 $self->check_price_factor($entry);
426 $self->check_pricegroup($entry);
430 my ($self, $entry) = @_;
432 my $object = $entry->{object};
434 # Check wether or non part ID is valid.
435 if ($object->parts_id && !$self->parts_by->{id}->{ $object->parts_id }) {
436 push @{ $entry->{errors} }, $::locale->text('Error: Invalid part');
440 # Map number to ID if given.
441 if (!$object->parts_id && $entry->{raw_data}->{partnumber}) {
442 my $part = $self->parts_by->{partnumber}->{ $entry->{raw_data}->{partnumber} };
444 push @{ $entry->{errors} }, $::locale->text('Error: Invalid part');
448 $object->parts_id($part->id);
451 if ($object->parts_id) {
452 $entry->{info_data}->{partnumber} = $self->parts_by->{id}->{ $object->parts_id }->partnumber;
454 push @{ $entry->{errors} }, $::locale->text('Error: Part not found');
462 my ($self, $entry) = @_;
464 my $object = $entry->{object};
466 my $cp_cv_id = $object->customer_id || $object->vendor_id;
467 return 0 unless $cp_cv_id;
469 # Check wether or not contact ID is valid.
470 if ($object->cp_id && !$self->contacts_by->{'cp_cv_id+cp_id'}->{ $cp_cv_id . '+' . $object->cp_id }) {
471 push @{ $entry->{errors} }, $::locale->text('Error: Invalid contact');
475 # Map name to ID if given.
476 if (!$object->cp_id && $entry->{raw_data}->{contact}) {
477 my $cp = $self->contacts_by->{'cp_cv_id+cp_name'}->{ $cp_cv_id . '+' . $entry->{raw_data}->{contact} };
479 push @{ $entry->{errors} }, $::locale->text('Error: Invalid contact');
483 $object->cp_id($cp->cp_id);
486 if ($object->cp_id) {
487 $entry->{info_data}->{contact} = $self->contacts_by->{'cp_cv_id+cp_id'}->{ $cp_cv_id . '+' . $object->cp_id }->cp_name;
493 sub check_department {
494 my ($self, $entry) = @_;
496 my $object = $entry->{object};
498 # Check wether or not department ID is valid.
499 if ($object->department_id && !$self->departments_by->{id}->{ $object->department_id }) {
500 push @{ $entry->{errors} }, $::locale->text('Error: Invalid department');
504 # Map description to ID if given.
505 if (!$object->department_id && $entry->{raw_data}->{department}) {
506 my $dep = $self->departments_by->{description}->{ $entry->{raw_data}->{department} };
508 push @{ $entry->{errors} }, $::locale->text('Error: Invalid department');
512 $object->department_id($dep->id);
519 my ($self, $entry, %params) = @_;
521 my $id_column = ($params{global} ? 'global' : '') . 'project_id';
522 my $number_column = ($params{global} ? 'global' : '') . 'projectnumber';
523 my $description_column = ($params{global} ? 'global' : '') . 'project';
525 my $object = $entry->{object};
527 # Check wether or not projetc ID is valid.
528 if ($object->$id_column && !$self->projects_by->{id}->{ $object->$id_column }) {
529 push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
533 # Map number to ID if given.
534 if (!$object->$id_column && $entry->{raw_data}->{$number_column}) {
535 my $proj = $self->projects_by->{projectnumber}->{ $entry->{raw_data}->{$number_column} };
537 push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
541 $object->$id_column($proj->id);
544 # Map description to ID if given.
545 if (!$object->$id_column && $entry->{raw_data}->{$description_column}) {
546 my $proj = $self->projects_by->{description}->{ $entry->{raw_data}->{$description_column} };
548 push @{ $entry->{errors} }, $::locale->text('Error: Invalid project');
552 $object->$id_column($proj->id);
558 sub check_ct_shipto {
559 my ($self, $entry) = @_;
561 my $object = $entry->{object};
563 my $trans_id = $object->customer_id || $object->vendor_id;
564 return 0 unless $trans_id;
566 # Check wether or not shipto ID is valid.
567 if ($object->shipto_id && !$self->ct_shiptos_by->{'trans_id+shipto_id'}->{ $trans_id . '+' . $object->shipto_id }) {
568 push @{ $entry->{errors} }, $::locale->text('Error: Invalid shipto');
576 my ($self, $entry) = @_;
578 my $object = $entry->{object};
580 # Check wether or not taxzone ID is valid.
581 if ($object->taxzone_id && !$self->taxzones_by->{id}->{ $object->taxzone_id }) {
582 push @{ $entry->{errors} }, $::locale->text('Error: Invalid tax zone');
586 # Map description to ID if given.
587 if (!$object->taxzone_id && $entry->{raw_data}->{taxzone}) {
588 my $taxzone = $self->taxzones_by->{description}->{ $entry->{raw_data}->{taxzone} };
590 push @{ $entry->{errors} }, $::locale->text('Error: Invalid tax zone');
594 $object->taxzone_id($taxzone->id);
600 sub check_price_factor {
601 my ($self, $entry) = @_;
603 my $object = $entry->{object};
605 # Check wether or not price_factor ID is valid.
606 if ($object->price_factor_id && !$self->price_factors_by->{id}->{ $object->price_factor_id }) {
607 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price factor');
611 # Map description to ID if given.
612 if (!$object->price_factor_id && $entry->{raw_data}->{price_factor}) {
613 my $price_factor = $self->price_factors_by->{description}->{ $entry->{raw_data}->{price_factor} };
614 if (!$price_factor) {
615 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price factor');
619 $object->price_factor_id($price_factor->id);
625 sub check_pricegroup {
626 my ($self, $entry) = @_;
628 my $object = $entry->{object};
630 # Check wether or not pricegroup ID is valid.
631 if ($object->pricegroup_id && !$self->pricegroups_by->{id}->{ $object->pricegroup_id }) {
632 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
636 # Map pricegroup to ID if given.
637 if (!$object->pricegroup_id && $entry->{raw_data}->{pricegroup}) {
638 my $pricegroup = $self->pricegroups_by->{pricegroup}->{ $entry->{raw_data}->{pricegroup} };
640 push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
644 $object->pricegroup_id($pricegroup->id);
650 sub add_items_to_order {
653 # add orderitems to order
656 foreach my $entry (@{ $self->controller->data }) {
658 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
660 # new order entry: add collected orderitems to the previous one
661 if (defined $order_entry) {
662 $order_entry->{object}->orderitems(@orderitems);
666 $order_entry = $entry;
668 } elsif ( defined $order_entry && $entry->{raw_data}->{datatype} eq $self->_item_column ) {
669 # collect orderitems to add to order (if they have no errors)
670 # ( add_orderitems does not work here if we want to call
671 # calculate_prices_and_taxes afterwards ...
672 # so collect orderitems and add them at once )
673 push @orderitems, $entry->{object} if (scalar @{ $entry->{errors} } == 0);
676 # add last collected orderitems to last order
677 $order_entry->{object}->orderitems(@orderitems) if $order_entry;
680 sub handle_prices_and_taxes() {
683 # calculate prices and taxes
684 foreach my $entry (@{ $self->controller->data }) {
685 next if @{ $entry->{errors} };
687 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
689 $entry->{object}->calculate_prices_and_taxes;
691 $entry->{info_data}->{calc_amount} = $entry->{object}->amount_as_number;
692 $entry->{info_data}->{calc_netamount} = $entry->{object}->netamount_as_number;
696 # If amounts are given, show calculated amounts as info and given amounts (verify_xxx).
697 # And throw an error if the differences are too big.
698 my @to_verify = ( { column => 'amount',
699 raw_column => 'verify_amount',
700 info_header => 'Calc. Amount',
701 info_method => 'calc_amount',
702 err_msg => 'Amounts differ too much',
704 { column => 'netamount',
705 raw_column => 'verify_netamount',
706 info_header => 'Calc. Net amount',
707 info_method => 'calc_netamount',
708 err_msg => 'Net amounts differ too much',
711 foreach my $tv (@to_verify) {
712 # Todo: access via ->[0] ok? Better: search first order column and use this
713 if (exists $self->controller->data->[0]->{raw_data}->{ $tv->{raw_column} }) {
714 $self->add_raw_data_columns($self->_order_column, $tv->{raw_column});
715 $self->add_info_columns($self->_order_column,
716 { header => $::locale->text($tv->{info_header}), method => $tv->{info_method} });
720 foreach my $entry (@{ $self->controller->data }) {
721 next if @{ $entry->{errors} };
722 if ($entry->{raw_data}->{datatype} eq $self->_order_column) {
723 next if !$entry->{raw_data}->{ $tv->{raw_column} };
724 my $parsed_value = $::form->parse_amount(\%::myconfig, $entry->{raw_data}->{ $tv->{raw_column} });
725 if (abs($entry->{object}->${ \$tv->{column} } - $parsed_value) > $self->settings->{'max_amount_diff'}) {
726 push @{ $entry->{errors} }, $::locale->text($tv->{err_msg});
735 my ($self, %params) = @_;
737 # set order number and collect to save
739 foreach my $entry (@{ $self->controller->data }) {
740 next if $entry->{raw_data}->{datatype} ne $self->_order_column;
741 next if @{ $entry->{errors} };
743 if (!$entry->{object}->ordnumber) {
744 my $number = SL::TransNumber->new(type => 'sales_order',
746 $entry->{object}->ordnumber($number->create_unique());
749 push @{ $objects_to_save }, $entry;
752 $self->SUPER::save_objects(data => $objects_to_save);
756 $_[0]->settings->{'order_column'}
760 $_[0]->settings->{'item_column'}