|
Lines 90-96
sub import_record_and_create_order_lines {
Link Here
|
| 90 |
my $budget_id = $args->{budget_id}; |
90 |
my $budget_id = $args->{budget_id}; |
| 91 |
my $vendor = $args->{vendor}; |
91 |
my $vendor = $args->{vendor}; |
| 92 |
|
92 |
|
| 93 |
my $result = add_biblios_from_import_record( |
93 |
my $result = add_biblio_from_import_record( |
| 94 |
{ |
94 |
{ |
| 95 |
import_batch_id => $import_batch_id, |
95 |
import_batch_id => $import_batch_id, |
| 96 |
import_record => $import_record, |
96 |
import_record => $import_record, |
|
Lines 167-174
sub _get_MarcFieldsToOrder_syspref_data {
Link Here
|
| 167 |
=cut |
167 |
=cut |
| 168 |
|
168 |
|
| 169 |
sub _get_MarcItemFieldsToOrder_syspref_data { |
169 |
sub _get_MarcItemFieldsToOrder_syspref_data { |
| 170 |
my ( $syspref_name, $record, $field_list ) = @_; |
170 |
my ($record) = @_; |
| 171 |
my $syspref = C4::Context->preference($syspref_name); |
171 |
my $syspref = C4::Context->preference('MarcItemFieldsToOrder'); |
| 172 |
$syspref = "$syspref\n\n"; |
172 |
$syspref = "$syspref\n\n"; |
| 173 |
my $yaml = eval { YAML::XS::Load( Encode::encode_utf8($syspref) ); }; |
173 |
my $yaml = eval { YAML::XS::Load( Encode::encode_utf8($syspref) ); }; |
| 174 |
if ($@) { |
174 |
if ($@) { |
|
Lines 179-186
sub _get_MarcItemFieldsToOrder_syspref_data {
Link Here
|
| 179 |
my @tags_list; |
179 |
my @tags_list; |
| 180 |
|
180 |
|
| 181 |
# Check tags in syspref definition |
181 |
# Check tags in syspref definition |
| 182 |
for my $field_name (@$field_list) { |
182 |
for my $field_name ( keys %$yaml ) { |
| 183 |
next unless exists $yaml->{$field_name}; |
|
|
| 184 |
my @fields = split /\|/, $yaml->{$field_name}; |
183 |
my @fields = split /\|/, $yaml->{$field_name}; |
| 185 |
for my $field (@fields) { |
184 |
for my $field (@fields) { |
| 186 |
my ( $f, $sf ) = split /\$/, $field; |
185 |
my ( $f, $sf ) = split /\$/, $field; |
|
Lines 208-215
sub _get_MarcItemFieldsToOrder_syspref_data {
Link Here
|
| 208 |
if ( $tags_count->{count} ) { |
207 |
if ( $tags_count->{count} ) { |
| 209 |
for ( my $i = 0 ; $i < $tags_count->{count} ; $i++ ) { |
208 |
for ( my $i = 0 ; $i < $tags_count->{count} ; $i++ ) { |
| 210 |
my $r; |
209 |
my $r; |
| 211 |
for my $field_name (@$field_list) { |
210 |
for my $field_name ( keys %$yaml ) { |
| 212 |
next unless exists $yaml->{$field_name}; |
|
|
| 213 |
my @fields = split /\|/, $yaml->{$field_name}; |
211 |
my @fields = split /\|/, $yaml->{$field_name}; |
| 214 |
for my $field (@fields) { |
212 |
for my $field (@fields) { |
| 215 |
my ( $f, $sf ) = split /\$/, $field; |
213 |
my ( $f, $sf ) = split /\$/, $field; |
|
Lines 254-262
sub _verify_number_of_fields {
Link Here
|
| 254 |
return { error => 0, count => $tags_count }; |
252 |
return { error => 0, count => $tags_count }; |
| 255 |
} |
253 |
} |
| 256 |
|
254 |
|
| 257 |
=head3 add_biblios_from_import_record |
255 |
=head3 add_biblio_from_import_record |
| 258 |
|
256 |
|
| 259 |
my ($record_results, $duplicates_in_batch) = add_biblios_from_import_record({ |
257 |
my ($record_results, $duplicates_in_batch) = add_biblio_from_import_record({ |
| 260 |
import_record => $import_record, |
258 |
import_record => $import_record, |
| 261 |
matcher_id => $matcher_id, |
259 |
matcher_id => $matcher_id, |
| 262 |
overlay_action => $overlay_action, |
260 |
overlay_action => $overlay_action, |
|
Lines 271-277
sub _verify_number_of_fields {
Link Here
|
| 271 |
|
269 |
|
| 272 |
=cut |
270 |
=cut |
| 273 |
|
271 |
|
| 274 |
sub add_biblios_from_import_record { |
272 |
sub add_biblio_from_import_record { |
| 275 |
my ($args) = @_; |
273 |
my ($args) = @_; |
| 276 |
|
274 |
|
| 277 |
my $import_batch_id = $args->{import_batch_id}; |
275 |
my $import_batch_id = $args->{import_batch_id}; |
|
Lines 369-638
sub add_items_from_import_record {
Link Here
|
| 369 |
my $active_currency = Koha::Acquisition::Currencies->get_active; |
367 |
my $active_currency = Koha::Acquisition::Currencies->get_active; |
| 370 |
my $biblionumber = $record_result->{biblionumber}; |
368 |
my $biblionumber = $record_result->{biblionumber}; |
| 371 |
my $marcrecord = $record_result->{marcrecord}; |
369 |
my $marcrecord = $record_result->{marcrecord}; |
| 372 |
my @order_line_details; |
|
|
| 373 |
|
370 |
|
| 374 |
if ( $agent eq 'cron' ) { |
371 |
if ( $agent eq 'cron' ) { |
| 375 |
my $marc_fields_to_order = _get_MarcFieldsToOrder_syspref_data( |
372 |
my $marc_fields_to_order = _get_MarcFieldsToOrder_syspref_data( |
| 376 |
'MarcFieldsToOrder', $marcrecord, |
373 |
'MarcFieldsToOrder', $marcrecord, |
| 377 |
[ 'price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2' ] |
374 |
[ 'price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2' ] |
| 378 |
); |
375 |
); |
| 379 |
my $quantity = $marc_fields_to_order->{quantity}; |
|
|
| 380 |
my $budget_code = |
| 381 |
$marc_fields_to_order->{budget_code} || $budget_id; # Use fallback from ordering profile if not mapped |
| 382 |
my $price = $marc_fields_to_order->{price}; |
| 383 |
my $discount = $marc_fields_to_order->{discount}; |
| 384 |
my $sort1 = $marc_fields_to_order->{sort1}; |
| 385 |
my $sort2 = $marc_fields_to_order->{sort2}; |
| 386 |
my $mapped_budget; |
| 387 |
|
| 388 |
if ($budget_code) { |
| 389 |
my $biblio_budget = GetBudgetByCode($budget_code); |
| 390 |
if ($biblio_budget) { |
| 391 |
$mapped_budget = $biblio_budget->{budget_id}; |
| 392 |
} else { |
| 393 |
$mapped_budget = $budget_id; |
| 394 |
} |
| 395 |
} |
| 396 |
|
376 |
|
| 397 |
my $marc_item_fields_to_order = _get_MarcItemFieldsToOrder_syspref_data( |
377 |
my $marc_item_fields_to_order = _get_MarcItemFieldsToOrder_syspref_data($marcrecord); |
| 398 |
'MarcItemFieldsToOrder', |
378 |
|
| 399 |
$marcrecord, |
379 |
my $item_fields = { |
| 400 |
[ |
380 |
homebranch => $marc_item_fields_to_order->{homebranch}, |
| 401 |
'homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', |
381 |
holdingbranch => $marc_item_fields_to_order->{holdingbranch}, |
| 402 |
'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code' |
382 |
itype => $marc_item_fields_to_order->{itype}, |
| 403 |
] |
383 |
nonpublic_note => $marc_item_fields_to_order->{nonpublic_note}, |
| 404 |
); |
384 |
public_note => $marc_item_fields_to_order->{public_note}, |
| 405 |
my $item_homebranch = $marc_item_fields_to_order->{homebranch}; |
385 |
loc => $marc_item_fields_to_order->{loc}, |
| 406 |
my $item_holdingbranch = $marc_item_fields_to_order->{holdingbranch}; |
386 |
ccode => $marc_item_fields_to_order->{ccode}, |
| 407 |
my $item_itype = $marc_item_fields_to_order->{itype}; |
387 |
notforloan => $marc_item_fields_to_order->{notforloan}, |
| 408 |
my $item_nonpublic_note = $marc_item_fields_to_order->{nonpublic_note}; |
388 |
uri => $marc_item_fields_to_order->{uri}, |
| 409 |
my $item_public_note = $marc_item_fields_to_order->{public_note}; |
389 |
copyno => $marc_item_fields_to_order->{copyno}, |
| 410 |
my $item_loc = $marc_item_fields_to_order->{loc}; |
390 |
quantity => $marc_item_fields_to_order->{quantity}, |
| 411 |
my $item_ccode = $marc_item_fields_to_order->{ccode}; |
391 |
price => $marc_item_fields_to_order->{price}, |
| 412 |
my $item_notforloan = $marc_item_fields_to_order->{notforloan}; |
392 |
replacementprice => $marc_item_fields_to_order->{replacementprice}, |
| 413 |
my $item_uri = $marc_item_fields_to_order->{uri}; |
393 |
itemcallnumber => $marc_item_fields_to_order->{itemcallnumber}, |
| 414 |
my $item_copyno = $marc_item_fields_to_order->{copyno}; |
394 |
budget_code => $marc_item_fields_to_order->{budget_code}, |
| 415 |
my $item_quantity = $marc_item_fields_to_order->{quantity} || 0; |
395 |
c_quantity => $marc_fields_to_order->{quantity}, |
| 416 |
my $item_budget_code = $marc_item_fields_to_order->{budget_code}; |
396 |
c_budget_code => $marc_fields_to_order->{budget_code}, |
| 417 |
my $item_budget_id; |
397 |
c_price => $marc_fields_to_order->{price}, |
| 418 |
|
398 |
c_discount => $marc_fields_to_order->{discount}, |
| 419 |
if ( $marc_item_fields_to_order->{budget_code} ) { |
399 |
c_sort1 => $marc_fields_to_order->{sort1}, |
| 420 |
my $item_budget = GetBudgetByCode( $marc_item_fields_to_order->{budget_code} ); |
400 |
c_sort2 => $marc_fields_to_order->{sort2}, |
| 421 |
if ($item_budget) { |
401 |
}; |
| 422 |
$item_budget_id = $item_budget->{budget_id}; |
402 |
|
| 423 |
} else { |
403 |
my $order_line_fields = parse_input_into_order_line_fields( |
| 424 |
$item_budget_id = $budget_id; |
404 |
{ |
| 425 |
} |
405 |
agent => $agent, |
| 426 |
} else { |
|
|
| 427 |
$item_budget_id = $budget_id; |
| 428 |
} |
| 429 |
my $item_price = $marc_item_fields_to_order->{price}; |
| 430 |
my $item_replacement_price = $marc_item_fields_to_order->{replacementprice}; |
| 431 |
my $item_callnumber = $marc_item_fields_to_order->{itemcallnumber}; |
| 432 |
my $itemcreation = 0; |
| 433 |
|
| 434 |
for ( my $i = 0 ; $i < $item_quantity ; $i++ ) { |
| 435 |
$itemcreation = 1; |
| 436 |
my $item = Koha::Item->new( |
| 437 |
{ |
| 438 |
biblionumber => $biblionumber, |
| 439 |
homebranch => $item_homebranch, |
| 440 |
holdingbranch => $item_holdingbranch, |
| 441 |
itype => $item_itype, |
| 442 |
itemnotes_nonpublic => $item_nonpublic_note, |
| 443 |
itemnotes => $item_public_note, |
| 444 |
location => $item_loc, |
| 445 |
ccode => $item_ccode, |
| 446 |
notforloan => $item_notforloan, |
| 447 |
uri => $item_uri, |
| 448 |
copynumber => $item_copyno, |
| 449 |
price => $item_price, |
| 450 |
replacementprice => $item_replacement_price, |
| 451 |
itemcallnumber => $item_callnumber, |
| 452 |
} |
| 453 |
)->store; |
| 454 |
|
| 455 |
my %order_detail_hash = ( |
| 456 |
biblionumber => $biblionumber, |
406 |
biblionumber => $biblionumber, |
| 457 |
basketno => $basket_id, |
407 |
budget_id => $budget_id, |
| 458 |
itemnumbers => ( $item->itemnumber ), |
408 |
basket_id => $basket_id, |
| 459 |
quantity => 1, |
409 |
fields => $item_fields, |
| 460 |
budget_id => $item_budget_id, |
|
|
| 461 |
currency => $vendor->listprice, |
| 462 |
); |
| 463 |
|
| 464 |
if ($item_price) { |
| 465 |
$order_detail_hash{tax_rate_on_ordering} = $vendor->tax_rate; |
| 466 |
$order_detail_hash{tax_rate_on_receiving} = $vendor->tax_rate; |
| 467 |
$order_detail_hash{discount} = $vendor->discount; |
| 468 |
$order_detail_hash{rrp} = $item_price; |
| 469 |
$order_detail_hash{ecost} = |
| 470 |
$vendor->discount ? $item_price * ( 1 - $vendor->discount / 100 ) : $item_price; |
| 471 |
$order_detail_hash{listprice} = $order_detail_hash{rrp} / $active_currency->rate; |
| 472 |
$order_detail_hash{unitprice} = $order_detail_hash{ecost}; |
| 473 |
} else { |
| 474 |
$order_detail_hash{listprice} = 0; |
| 475 |
} |
410 |
} |
| 476 |
$order_detail_hash{replacementprice} = $item_replacement_price || 0; |
411 |
); |
| 477 |
$order_detail_hash{uncertainprice} = 0 if $order_detail_hash{listprice}; |
|
|
| 478 |
|
| 479 |
push @order_line_details, \%order_detail_hash; |
| 480 |
} |
| 481 |
|
412 |
|
| 482 |
if ( !$itemcreation ) { |
413 |
my $order_line_details = create_items_and_generate_order_hash( |
| 483 |
my %order_detail_hash = ( |
414 |
{ |
| 484 |
biblionumber => $biblionumber, |
415 |
fields => $order_line_fields, |
| 485 |
basketno => $basket_id, |
416 |
vendor => $vendor, |
| 486 |
quantity => $quantity, |
417 |
agent => $agent, |
| 487 |
budget_id => $mapped_budget, |
418 |
active_currency => $active_currency, |
| 488 |
uncertainprice => 1, |
|
|
| 489 |
sort1 => $sort1, |
| 490 |
sort2 => $sort2, |
| 491 |
); |
| 492 |
|
| 493 |
if ($price) { |
| 494 |
$order_detail_hash{tax_rate_on_ordering} = $vendor->tax_rate; |
| 495 |
$order_detail_hash{tax_rate_on_receiving} = $vendor->tax_rate; |
| 496 |
my $order_discount = $discount ? $discount : $vendor->discount; |
| 497 |
$order_detail_hash{discount} = $order_discount; |
| 498 |
$order_detail_hash{rrp} = $price; |
| 499 |
$order_detail_hash{ecost} = $order_discount ? $price * ( 1 - $order_discount / 100 ) : $price; |
| 500 |
$order_detail_hash{listprice} = $order_detail_hash{rrp} / $active_currency->rate; |
| 501 |
$order_detail_hash{unitprice} = $order_detail_hash{ecost}; |
| 502 |
} else { |
| 503 |
$order_detail_hash{listprice} = 0; |
| 504 |
} |
419 |
} |
|
|
420 |
); |
| 505 |
|
421 |
|
| 506 |
$order_detail_hash{uncertainprice} = 0 if $order_detail_hash{listprice}; |
422 |
return $order_line_details; |
| 507 |
push @order_line_details, \%order_detail_hash; |
|
|
| 508 |
} |
| 509 |
} |
423 |
} |
| 510 |
|
424 |
|
| 511 |
if ( $agent eq 'client' ) { |
425 |
if ( $agent eq 'client' ) { |
| 512 |
my $homebranches = $client_item_fields->{homebranches}; |
426 |
my $order_line_fields = parse_input_into_order_line_fields( |
| 513 |
my $count = scalar @$homebranches; |
427 |
{ |
| 514 |
my $holdingbranches = $client_item_fields->{holdingbranches}; |
428 |
agent => $agent, |
| 515 |
my $itypes = $client_item_fields->{itypes}; |
|
|
| 516 |
my $nonpublic_notes = $client_item_fields->{nonpublic_notes}; |
| 517 |
my $public_notes = $client_item_fields->{public_notes}; |
| 518 |
my $locs = $client_item_fields->{locs}; |
| 519 |
my $ccodes = $client_item_fields->{ccodes}; |
| 520 |
my $notforloans = $client_item_fields->{notforloans}; |
| 521 |
my $uris = $client_item_fields->{uris}; |
| 522 |
my $copynos = $client_item_fields->{copynos}; |
| 523 |
my $budget_codes = $client_item_fields->{budget_codes}; |
| 524 |
my $itemprices = $client_item_fields->{itemprices}; |
| 525 |
my $replacementprices = $client_item_fields->{replacementprices}; |
| 526 |
my $itemcallnumbers = $client_item_fields->{itemcallnumbers}; |
| 527 |
|
| 528 |
my $itemcreation; |
| 529 |
for ( my $i = 0 ; $i < $count ; $i++ ) { |
| 530 |
$itemcreation = 1; |
| 531 |
my $item = Koha::Item->new( |
| 532 |
{ |
| 533 |
biblionumber => $biblionumber, |
| 534 |
homebranch => @$homebranches[$i], |
| 535 |
holdingbranch => @$holdingbranches[$i], |
| 536 |
itemnotes_nonpublic => @$nonpublic_notes[$i], |
| 537 |
itemnotes => @$public_notes[$i], |
| 538 |
location => @$locs[$i], |
| 539 |
ccode => @$ccodes[$i], |
| 540 |
itype => @$itypes[$i], |
| 541 |
notforloan => @$notforloans[$i], |
| 542 |
uri => @$uris[$i], |
| 543 |
copynumber => @$copynos[$i], |
| 544 |
price => @$itemprices[$i], |
| 545 |
replacementprice => @$replacementprices[$i], |
| 546 |
itemcallnumber => @$itemcallnumbers[$i], |
| 547 |
} |
| 548 |
)->store; |
| 549 |
|
| 550 |
my %order_detail_hash = ( |
| 551 |
biblionumber => $biblionumber, |
429 |
biblionumber => $biblionumber, |
| 552 |
itemnumbers => ( $item->itemnumber ), |
430 |
budget_id => $budget_id, |
| 553 |
basketno => $basket_id, |
431 |
basket_id => $basket_id, |
| 554 |
quantity => 1, |
432 |
fields => $client_item_fields, |
| 555 |
budget_id => @$budget_codes[$i] |
|
|
| 556 |
|| $budget_id, # If no budget selected in the UI, default to the budget on the ordering account |
| 557 |
currency => $vendor->listprice, |
| 558 |
); |
| 559 |
|
| 560 |
if ( @$itemprices[$i] ) { |
| 561 |
$order_detail_hash{tax_rate_on_ordering} = $vendor->tax_rate; |
| 562 |
$order_detail_hash{tax_rate_on_receiving} = $vendor->tax_rate; |
| 563 |
my $order_discount = |
| 564 |
$client_item_fields->{c_discount} ? $client_item_fields->{c_discount} : $vendor->discount; |
| 565 |
$order_detail_hash{discount} = $order_discount; |
| 566 |
$order_detail_hash{rrp} = @$itemprices[$i]; |
| 567 |
$order_detail_hash{ecost} = |
| 568 |
$order_discount ? @$itemprices[$i] * ( 1 - $order_discount / 100 ) : @$itemprices[$i]; |
| 569 |
$order_detail_hash{listprice} = $order_detail_hash{rrp} / $active_currency->rate; |
| 570 |
$order_detail_hash{unitprice} = $order_detail_hash{ecost}; |
| 571 |
} else { |
| 572 |
$order_detail_hash{listprice} = 0; |
| 573 |
} |
433 |
} |
| 574 |
$order_detail_hash{replacementprice} = @$replacementprices[$i] || 0; |
434 |
); |
| 575 |
$order_detail_hash{uncertainprice} = 0 if $order_detail_hash{listprice}; |
|
|
| 576 |
|
| 577 |
push @order_line_details, \%order_detail_hash; |
| 578 |
} |
| 579 |
|
435 |
|
| 580 |
if ( !$itemcreation ) { |
436 |
my $order_line_details = create_items_and_generate_order_hash( |
| 581 |
my $quantity = GetMarcQuantity( $marcrecord, C4::Context->preference('marcflavour') ) || 1; |
437 |
{ |
| 582 |
my %order_detail_hash = ( |
438 |
fields => $order_line_fields, |
| 583 |
biblionumber => $biblionumber, |
439 |
vendor => $vendor, |
| 584 |
basketno => $basket_id, |
440 |
agent => $agent, |
| 585 |
quantity => $client_item_fields->{c_quantity}, |
441 |
active_currency => $active_currency, |
| 586 |
budget_id => $client_item_fields->{c_budget_id}, |
|
|
| 587 |
uncertainprice => 1, |
| 588 |
sort1 => $client_item_fields->{c_sort1}, |
| 589 |
sort2 => $client_item_fields->{c_sort2}, |
| 590 |
order_internalnote => $client_item_fields->{all_order_internalnote}, |
| 591 |
order_vendornote => $client_item_fields->{all_order_vendornote}, |
| 592 |
currency => $client_item_fields->{all_currency}, |
| 593 |
replacementprice => $client_item_fields->{c_replacement_price}, |
| 594 |
); |
| 595 |
if ( $client_item_fields->{c_price} ) { |
| 596 |
$order_detail_hash{tax_rate_on_ordering} = $vendor->tax_rate; |
| 597 |
$order_detail_hash{tax_rate_on_receiving} = $vendor->tax_rate; |
| 598 |
my $order_discount = |
| 599 |
$client_item_fields->{c_discount} ? $client_item_fields->{c_discount} : $vendor->discount; |
| 600 |
$order_detail_hash{discount} = $order_discount; |
| 601 |
$order_detail_hash{rrp} = $client_item_fields->{c_price}; |
| 602 |
$order_detail_hash{ecost} = |
| 603 |
$order_discount |
| 604 |
? $client_item_fields->{c_price} * ( 1 - $order_discount / 100 ) |
| 605 |
: $client_item_fields->{c_price}; |
| 606 |
$order_detail_hash{listprice} = $order_detail_hash{rrp} / $active_currency->rate; |
| 607 |
$order_detail_hash{unitprice} = $order_detail_hash{ecost}; |
| 608 |
} else { |
| 609 |
$order_detail_hash{listprice} = 0; |
| 610 |
} |
442 |
} |
|
|
443 |
); |
| 611 |
|
444 |
|
| 612 |
$order_detail_hash{uncertainprice} = 0 if $order_detail_hash{listprice}; |
445 |
return $order_line_details; |
| 613 |
|
|
|
| 614 |
# Add items if applicable parsing the item sent by the form, and create an item just for the import_record_id we are dealing with |
| 615 |
my $basket = Koha::Acquisition::Baskets->find($basket_id); |
| 616 |
$order_detail_hash{itemnumbers} = (); |
| 617 |
if ( $basket->effective_create_items eq 'ordering' && !$basket->is_standing ) { |
| 618 |
my @tags = $client_item_fields->{tag}; |
| 619 |
my @subfields = $client_item_fields->{subfield}; |
| 620 |
my @field_values = $client_item_fields->{field_value}; |
| 621 |
my @serials = $client_item_fields->{serial}; |
| 622 |
my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values ); |
| 623 |
my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' ); |
| 624 |
for ( my $qtyloop = 1 ; $qtyloop <= $client_item_fields->{c_quantity} ; $qtyloop++ ) { |
| 625 |
my ( $biblionumber, undef, $itemnumber ) = AddItemFromMarc( $record, $biblionumber ); |
| 626 |
push @{ $order_detail_hash{itemnumbers} }, $itemnumber; |
| 627 |
} |
| 628 |
} |
| 629 |
push @order_line_details, \%order_detail_hash; |
| 630 |
} |
| 631 |
} |
446 |
} |
| 632 |
return \@order_line_details; |
447 |
|
|
|
448 |
# return \@order_line_details; |
| 633 |
} |
449 |
} |
| 634 |
|
450 |
|
| 635 |
=head3 create_order_lines |
451 |
=head3 create_items_and_generate_order_hash |
| 636 |
|
452 |
|
| 637 |
my $order_lines = create_order_lines({ |
453 |
my $order_lines = create_order_lines({ |
| 638 |
order_line_details => $order_line_details |
454 |
order_line_details => $order_line_details |
|
Lines 663-676
sub create_order_lines {
Link Here
|
| 663 |
|
479 |
|
| 664 |
=head3 import_batches_list |
480 |
=head3 import_batches_list |
| 665 |
|
481 |
|
| 666 |
Fetches import batches matching the batch to be added to the basket and adds these to the $template |
482 |
Fetches import batches matching the batch to be added to the basket and returns these to the template |
| 667 |
|
483 |
|
| 668 |
Koha::MarcOrder->import_batches_list($template); |
484 |
Koha::MarcOrder->import_batches_list(); |
| 669 |
|
485 |
|
| 670 |
=cut |
486 |
=cut |
| 671 |
|
487 |
|
| 672 |
sub import_batches_list { |
488 |
sub import_batches_list { |
| 673 |
my ( $self, $template ) = @_; |
489 |
my ($self) = @_; |
| 674 |
my $batches = GetImportBatchRangeDesc(); |
490 |
my $batches = GetImportBatchRangeDesc(); |
| 675 |
|
491 |
|
| 676 |
my @list = (); |
492 |
my @list = (); |
|
Lines 702-723
sub import_batches_list {
Link Here
|
| 702 |
} |
518 |
} |
| 703 |
} |
519 |
} |
| 704 |
} |
520 |
} |
| 705 |
$template->param( batch_list => \@list ); |
|
|
| 706 |
my $num_batches = GetNumberOfNonZ3950ImportBatches(); |
521 |
my $num_batches = GetNumberOfNonZ3950ImportBatches(); |
| 707 |
$template->param( num_results => $num_batches ); |
522 |
|
|
|
523 |
return { |
| 524 |
list => \@list, |
| 525 |
num_results => $num_batches |
| 526 |
}; |
| 708 |
} |
527 |
} |
| 709 |
|
528 |
|
| 710 |
=head3 |
529 |
=head3 |
| 711 |
|
530 |
|
| 712 |
For an import batch, this function reads the files and creates all the relevant data pertaining to that file |
531 |
For an import batch, this function reads the files and creates all the relevant data pertaining to that file |
| 713 |
It then passes this to the $template variable to be shown in the UI |
532 |
It then returns this to the template to be shown in the UI |
| 714 |
|
533 |
|
| 715 |
Koha::MarcOrder->import_biblios_list( $template, $cgiparams->{'import_batch_id'} ); |
534 |
Koha::MarcOrder->import_biblios_list( $cgiparams->{'import_batch_id'} ); |
| 716 |
|
535 |
|
| 717 |
=cut |
536 |
=cut |
| 718 |
|
537 |
|
| 719 |
sub import_biblios_list { |
538 |
sub import_biblios_list { |
| 720 |
my ( $self, $template, $import_batch_id ) = @_; |
539 |
my ( $self, $import_batch_id ) = @_; |
| 721 |
my $batch = GetImportBatch( $import_batch_id, 'staged' ); |
540 |
my $batch = GetImportBatch( $import_batch_id, 'staged' ); |
| 722 |
return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/; |
541 |
return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/; |
| 723 |
my $import_records = Koha::Import::Records->search( |
542 |
my $import_records = Koha::Import::Records->search( |
|
Lines 806-868
sub import_biblios_list {
Link Here
|
| 806 |
# Items |
625 |
# Items |
| 807 |
my @itemlist = (); |
626 |
my @itemlist = (); |
| 808 |
my $all_items_quantity = 0; |
627 |
my $all_items_quantity = 0; |
| 809 |
my $alliteminfos = _get_MarcItemFieldsToOrder_syspref_data( |
628 |
my $alliteminfos = _get_MarcItemFieldsToOrder_syspref_data($marcrecord); |
| 810 |
'MarcItemFieldsToOrder', |
|
|
| 811 |
$marcrecord, |
| 812 |
[ |
| 813 |
'homebranch', 'holdingbranch', 'itype', 'nonpublic_note', 'public_note', 'loc', 'ccode', 'notforloan', |
| 814 |
'uri', 'copyno', 'price', 'replacementprice', 'itemcallnumber', 'quantity', 'budget_code' |
| 815 |
] |
| 816 |
); |
| 817 |
if ( !$alliteminfos || %$alliteminfos != -1 ) { |
629 |
if ( !$alliteminfos || %$alliteminfos != -1 ) { |
| 818 |
my $item_homebranch = $alliteminfos->{homebranch}; |
630 |
|
| 819 |
my $item_holdingbranch = $alliteminfos->{holdingbranch}; |
631 |
# Quantity is required, default to one if not supplied |
| 820 |
my $item_itype = $alliteminfos->{itype}; |
632 |
my $quantity = delete $alliteminfos->{quantity} || 1; |
| 821 |
my $item_nonpublic_note = $alliteminfos->{nonpublic_note}; |
633 |
|
| 822 |
my $item_public_note = $alliteminfos->{public_note}; |
634 |
# Handle incorrectly named original parameters for MarcItemFieldsToOrder |
| 823 |
my $item_loc = $alliteminfos->{loc}; |
635 |
$alliteminfos->{location} = delete $alliteminfos->{loc} if $alliteminfos->{loc}; |
| 824 |
my $item_ccode = $alliteminfos->{ccode}; |
636 |
$alliteminfos->{copynumber} = delete $alliteminfos->{copyno} if $alliteminfos->{copyno}; |
| 825 |
my $item_notforloan = $alliteminfos->{notforloan}; |
637 |
|
| 826 |
my $item_uri = $alliteminfos->{uri}; |
638 |
# Convert budget code to a budget id |
| 827 |
my $item_copyno = $alliteminfos->{copyno}; |
639 |
my $item_budget_code = delete $alliteminfos->{budget_code}; |
| 828 |
my $item_quantity = $alliteminfos->{quantity} || 1; |
640 |
if ($item_budget_code) { |
| 829 |
my $item_budget_code = $alliteminfos->{budget_code}; |
641 |
my $item_budget = GetBudgetByCode($item_budget_code); |
| 830 |
my $item_budget_id; |
642 |
$alliteminfos->{budget_id} = $item_budget->{budget_id} || $budget_id; |
| 831 |
|
|
|
| 832 |
if ( $alliteminfos->{budget_code} ) { |
| 833 |
my $item_budget = GetBudgetByCode( $alliteminfos->{budget_code} ); |
| 834 |
if ($item_budget) { |
| 835 |
$item_budget_id = $item_budget->{budget_id}; |
| 836 |
} |
| 837 |
} |
643 |
} |
| 838 |
my $item_price = $alliteminfos->{price}; |
|
|
| 839 |
my $item_replacement_price = $alliteminfos->{replacementprice}; |
| 840 |
my $item_callnumber = $alliteminfos->{itemcallnumber}; |
| 841 |
|
| 842 |
for ( my $i = 0 ; $i < $item_quantity ; $i++ ) { |
| 843 |
|
| 844 |
my %itemrecord = ( |
| 845 |
'item_id' => $item_id++, |
| 846 |
'biblio_count' => $biblio_count, |
| 847 |
'homebranch' => $item_homebranch, |
| 848 |
'holdingbranch' => $item_holdingbranch, |
| 849 |
'itype' => $item_itype, |
| 850 |
'nonpublic_note' => $item_nonpublic_note, |
| 851 |
'public_note' => $item_public_note, |
| 852 |
'loc' => $item_loc, |
| 853 |
'ccode' => $item_ccode, |
| 854 |
'notforloan' => $item_notforloan, |
| 855 |
'uri' => $item_uri, |
| 856 |
'copyno' => $item_copyno, |
| 857 |
'quantity' => $item_quantity, |
| 858 |
'budget_id' => $item_budget_id || $budget_id, |
| 859 |
'itemprice' => $item_price || $price, |
| 860 |
'replacementprice' => $item_replacement_price || $replacementprice, |
| 861 |
'itemcallnumber' => $item_callnumber, |
| 862 |
); |
| 863 |
$all_items_quantity++; |
| 864 |
push @itemlist, \%itemrecord; |
| 865 |
|
644 |
|
|
|
645 |
# Clone the item data for the needed quantity |
| 646 |
# Add the incremented item id for each item in that quantity |
| 647 |
for ( my $i = 0 ; $i < $quantity ; $i++ ) { |
| 648 |
my $itemrecord = {%$alliteminfos}; |
| 649 |
$itemrecord->{item_id} = $item_id++; |
| 650 |
|
| 651 |
# Rename price field to match UI |
| 652 |
$itemrecord->{itemprice} = delete $itemrecord->{price} if $itemrecord->{price}; |
| 653 |
$all_items_quantity++; |
| 654 |
push @itemlist, $itemrecord; |
| 866 |
} |
655 |
} |
| 867 |
|
656 |
|
| 868 |
$cellrecord{'iteminfos'} = \@itemlist; |
657 |
$cellrecord{'iteminfos'} = \@itemlist; |
|
Lines 893-973
sub import_biblios_list {
Link Here
|
| 893 |
my $overlay_action = GetImportBatchOverlayAction($import_batch_id); |
682 |
my $overlay_action = GetImportBatchOverlayAction($import_batch_id); |
| 894 |
my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id); |
683 |
my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id); |
| 895 |
my $item_action = GetImportBatchItemAction($import_batch_id); |
684 |
my $item_action = GetImportBatchItemAction($import_batch_id); |
| 896 |
$template->param( |
685 |
my $result = { |
| 897 |
import_biblio_list => \@list, |
686 |
import_biblio_list => \@list, |
| 898 |
num_results => $num_records, |
687 |
num_results => $num_records, |
| 899 |
import_batch_id => $import_batch_id, |
688 |
import_batch_id => $import_batch_id, |
| 900 |
"overlay_action_${overlay_action}" => 1, |
689 |
overlay_action => $overlay_action, |
| 901 |
overlay_action => $overlay_action, |
690 |
nomatch_action => $nomatch_action, |
| 902 |
"nomatch_action_${nomatch_action}" => 1, |
691 |
item_action => $item_action, |
| 903 |
nomatch_action => $nomatch_action, |
692 |
item_error => $item_error, |
| 904 |
"item_action_${item_action}" => 1, |
693 |
locationloop => \@locations, |
| 905 |
item_action => $item_action, |
694 |
ccodeloop => \@ccodes, |
| 906 |
item_error => $item_error, |
695 |
notforloanloop => \@notforloans, |
| 907 |
libraries => Koha::Libraries->search, |
696 |
batch => $batch, |
| 908 |
locationloop => \@locations, |
697 |
}; |
| 909 |
itemtypes => Koha::ItemTypes->search, |
|
|
| 910 |
ccodeloop => \@ccodes, |
| 911 |
notforloanloop => \@notforloans, |
| 912 |
); |
| 913 |
_batch_info( $template, $batch ); |
| 914 |
} |
| 915 |
|
| 916 |
=head3 |
| 917 |
|
| 918 |
Creates a hash of information to be used about an import batch in the template |
| 919 |
|
| 920 |
=cut |
| 921 |
|
698 |
|
| 922 |
sub _batch_info { |
|
|
| 923 |
my ( $template, $batch ) = @_; |
| 924 |
$template->param( |
| 925 |
batch_info => 1, |
| 926 |
file_name => $batch->{'file_name'}, |
| 927 |
comments => $batch->{'comments'}, |
| 928 |
import_status => $batch->{'import_status'}, |
| 929 |
upload_timestamp => $batch->{'upload_timestamp'}, |
| 930 |
num_records => $batch->{'num_records'}, |
| 931 |
num_items => $batch->{'num_items'} |
| 932 |
); |
| 933 |
if ( $batch->{'num_records'} > 0 ) { |
699 |
if ( $batch->{'num_records'} > 0 ) { |
| 934 |
if ( $batch->{'import_status'} eq 'staged' or $batch->{'import_status'} eq 'reverted' ) { |
700 |
if ( $batch->{'import_status'} eq 'staged' or $batch->{'import_status'} eq 'reverted' ) { |
| 935 |
$template->param( can_commit => 1 ); |
701 |
$result->{can_commit} = 1; |
| 936 |
} |
702 |
} |
| 937 |
if ( $batch->{'import_status'} eq 'imported' ) { |
703 |
if ( $batch->{'import_status'} eq 'imported' ) { |
| 938 |
$template->param( can_revert => 1 ); |
704 |
$result->{can_revert} = 1; |
| 939 |
} |
705 |
} |
| 940 |
} |
706 |
} |
| 941 |
if ( defined $batch->{'matcher_id'} ) { |
707 |
if ( defined $batch->{'matcher_id'} ) { |
| 942 |
my $matcher = C4::Matcher->fetch( $batch->{'matcher_id'} ); |
708 |
my $matcher = C4::Matcher->fetch( $batch->{'matcher_id'} ); |
| 943 |
if ( defined $matcher ) { |
709 |
if ( defined $matcher ) { |
| 944 |
$template->param( |
710 |
$result->{'current_matcher_id'} = $batch->{'matcher_id'}; |
| 945 |
'current_matcher_id' => $batch->{'matcher_id'}, |
711 |
$result->{'current_matcher_code'} = $matcher->code(); |
| 946 |
'current_matcher_code' => $matcher->code(), |
712 |
$result->{'current_matcher_description'} = $matcher->description(); |
| 947 |
'current_matcher_description' => $matcher->description() |
|
|
| 948 |
); |
| 949 |
} |
713 |
} |
| 950 |
} |
714 |
} |
| 951 |
_add_matcher_list( $batch->{'matcher_id'}, $template ); |
715 |
|
|
|
716 |
my @matchers = C4::Matcher::GetMatcherList(); |
| 717 |
if ( defined $batch->{'matcher_id'} ) { |
| 718 |
for ( my $i = 0 ; $i <= $#matchers ; $i++ ) { |
| 719 |
if ( $matchers[$i]->{'matcher_id'} == $batch->{'matcher_id'} ) { |
| 720 |
$matchers[$i]->{'selected'} = 1; |
| 721 |
} |
| 722 |
} |
| 723 |
} |
| 724 |
$result->{available_matchers} = \@matchers; |
| 725 |
|
| 726 |
return $result; |
| 952 |
} |
727 |
} |
| 953 |
|
728 |
|
| 954 |
=head3 |
729 |
=head3 parse_input_into_order_line_fields |
|
|
730 |
|
| 731 |
This function takes inputs from either the cronjob or UI and then parses that into a single set of order line fields that can be used to create items and order lines |
| 732 |
|
| 733 |
my $order_line_fields = parse_input_into_order_line_fields( |
| 734 |
{ |
| 735 |
agent => $agent, |
| 736 |
biblionumber => $biblionumber, |
| 737 |
budget_id => $budget_id, |
| 738 |
basket_id => $basket_id, |
| 739 |
fields => $item_fields, |
| 740 |
} |
| 741 |
); |
| 955 |
|
742 |
|
| 956 |
Adds a list of available matchers based on an import batch |
|
|
| 957 |
|
743 |
|
| 958 |
=cut |
744 |
=cut |
| 959 |
|
745 |
|
| 960 |
sub _add_matcher_list { |
746 |
sub parse_input_into_order_line_fields { |
| 961 |
my ( $current_matcher_id, $template ) = @_; |
747 |
my ($args) = @_; |
| 962 |
my @matchers = C4::Matcher::GetMatcherList(); |
748 |
|
| 963 |
if ( defined $current_matcher_id ) { |
749 |
my $agent = $args->{agent}; |
| 964 |
for ( my $i = 0 ; $i <= $#matchers ; $i++ ) { |
750 |
my $client = $agent eq 'client' ? 1 : 0; |
| 965 |
if ( $matchers[$i]->{'matcher_id'} == $current_matcher_id ) { |
751 |
my $biblionumber = $args->{biblionumber}; |
| 966 |
$matchers[$i]->{'selected'} = 1; |
752 |
my $budget_id = $args->{budget_id}; |
|
|
753 |
my $basket_id = $args->{basket_id}; |
| 754 |
my $fields = $args->{fields}; |
| 755 |
|
| 756 |
my $quantity = $fields->{quantity} || 1; |
| 757 |
my @homebranches = $client ? @{ $fields->{homebranches} } : ( ( $fields->{homebranch} ) x $quantity ); |
| 758 |
my @holdingbranches = $client ? @{ $fields->{holdingbranches} } : ( ( $fields->{holdingbranch} ) x $quantity ); |
| 759 |
my @itypes = $client ? @{ $fields->{itypes} } : ( ( $fields->{itype} ) x $quantity ); |
| 760 |
my @nonpublic_notes = $client ? @{ $fields->{nonpublic_notes} } : ( ( $fields->{nonpublic_note} ) x $quantity ); |
| 761 |
my @public_notes = $client ? @{ $fields->{public_notes} } : ( ( $fields->{public_note} ) x $quantity ); |
| 762 |
my @locs = $client ? @{ $fields->{locs} } : ( ( $fields->{loc} ) x $quantity ); |
| 763 |
my @ccodes = $client ? @{ $fields->{ccodes} } : ( ( $fields->{ccode} ) x $quantity ); |
| 764 |
my @notforloans = $client ? @{ $fields->{notforloans} } : ( ( $fields->{notforloan} ) x $quantity ); |
| 765 |
my @uris = $client ? @{ $fields->{uris} } : ( ( $fields->{uri} ) x $quantity ); |
| 766 |
my @copynos = $client ? @{ $fields->{copynos} } : ( ( $fields->{copyno} ) x $quantity ); |
| 767 |
my @itemprices = $client ? @{ $fields->{itemprices} } : ( ( $fields->{price} ) x $quantity ); |
| 768 |
my @replacementprices = |
| 769 |
$client ? @{ $fields->{replacementprices} } : ( ( $fields->{replacementprice} ) x $quantity ); |
| 770 |
my @itemcallnumbers = $client ? @{ $fields->{itemcallnumbers} } : ( ( $fields->{itemcallnumber} ) x $quantity ); |
| 771 |
my $c_quantity = $client ? $fields->{c_quantity} : $fields->{c_quantity}; |
| 772 |
my $c_budget_id = $client ? $fields->{c_budget_id} : $fields->{c_budget_id}; |
| 773 |
my $c_discount = $client ? $fields->{c_discount} : $fields->{c_discount}; |
| 774 |
my $c_sort1 = $client ? $fields->{c_sort1} : $fields->{c_sort1}; |
| 775 |
my $c_sort2 = $client ? $fields->{c_sort2} : $fields->{c_sort2}; |
| 776 |
my $c_replacement_price = $client ? $fields->{c_replacement_price} : $fields->{c_replacement_price}; |
| 777 |
my $c_price = $client ? $fields->{c_price} : $fields->{c_price}; |
| 778 |
|
| 779 |
# If using the cronjob, we want to default to the account budget if not mapped on the record |
| 780 |
my $item_budget_id; |
| 781 |
if ( !$client && ( $fields->{budget_code} || $fields->{c_budget_code} ) ) { |
| 782 |
my $budget_code = $fields->{budget_code} || $fields->{c_budget_code}; |
| 783 |
my $item_budget = GetBudgetByCode($budget_code); |
| 784 |
if ($item_budget) { |
| 785 |
$item_budget_id = $item_budget->{budget_id}; |
| 786 |
} else { |
| 787 |
$item_budget_id = $budget_id; |
| 788 |
} |
| 789 |
} else { |
| 790 |
$item_budget_id = $budget_id; |
| 791 |
} |
| 792 |
my @budget_codes = $client ? @{ $fields->{budget_codes} } : ($item_budget_id); |
| 793 |
my $loop_limit = $client ? scalar(@homebranches) : $quantity; |
| 794 |
|
| 795 |
my $order_line_fields = { |
| 796 |
biblionumber => $biblionumber, |
| 797 |
homebranch => \@homebranches, |
| 798 |
holdingbranch => \@holdingbranches, |
| 799 |
itemnotes_nonpublic => \@nonpublic_notes, |
| 800 |
itemnotes => \@public_notes, |
| 801 |
location => \@locs, |
| 802 |
ccode => \@ccodes, |
| 803 |
itype => \@itypes, |
| 804 |
notforloan => \@notforloans, |
| 805 |
uri => \@uris, |
| 806 |
copynumber => \@copynos, |
| 807 |
price => \@itemprices, |
| 808 |
replacementprice => \@replacementprices, |
| 809 |
itemcallnumber => \@itemcallnumbers, |
| 810 |
budget_code => \@budget_codes, |
| 811 |
loop_limit => $loop_limit, |
| 812 |
basket_id => $basket_id, |
| 813 |
budget_id => $budget_id, |
| 814 |
c_quantity => $c_quantity, |
| 815 |
c_budget_id => $c_budget_id, |
| 816 |
c_discount => $c_discount, |
| 817 |
c_sort1 => $c_sort1, |
| 818 |
c_sort2 => $c_sort2, |
| 819 |
c_replacement_price => $c_replacement_price, |
| 820 |
c_price => $c_price, |
| 821 |
}; |
| 822 |
|
| 823 |
return $order_line_fields; |
| 824 |
} |
| 825 |
|
| 826 |
=head3 create_items_and_generate_order_hash |
| 827 |
|
| 828 |
This method is used from both the cronjob and the UI to create items and generate order line details for those new items |
| 829 |
|
| 830 |
my $order_line_details = create_items_and_generate_order_hash( |
| 831 |
{ |
| 832 |
fields => $order_line_fields, |
| 833 |
vendor => $vendor, |
| 834 |
agent => $agent, |
| 835 |
active_currency => $active_currency, |
| 836 |
} |
| 837 |
); |
| 838 |
|
| 839 |
=cut |
| 840 |
|
| 841 |
sub create_items_and_generate_order_hash { |
| 842 |
my ($args) = @_; |
| 843 |
|
| 844 |
my $agent = $args->{agent}; |
| 845 |
my $fields = $args->{fields}; |
| 846 |
my $loop_limit = $fields->{loop_limit}; |
| 847 |
my $basket_id = $fields->{basket_id}; |
| 848 |
my $budget_id = $fields->{budget_id}; |
| 849 |
my $vendor = $args->{vendor}; |
| 850 |
my $active_currency = $args->{active_currency}; |
| 851 |
my @order_line_details; |
| 852 |
my $itemcreation = 0; |
| 853 |
|
| 854 |
for ( my $i = 0 ; $i < $loop_limit ; $i++ ) { |
| 855 |
$itemcreation = 1; |
| 856 |
my $item = Koha::Item->new( |
| 857 |
{ |
| 858 |
biblionumber => $fields->{biblionumber}, |
| 859 |
homebranch => @{ $fields->{homebranch} }[$i], |
| 860 |
holdingbranch => @{ $fields->{holdingbranch} }[$i], |
| 861 |
itemnotes_nonpublic => @{ $fields->{itemnotes_nonpublic} }[$i], |
| 862 |
itemnotes => @{ $fields->{itemnotes} }[$i], |
| 863 |
location => @{ $fields->{location} }[$i], |
| 864 |
ccode => @{ $fields->{ccode} }[$i], |
| 865 |
itype => @{ $fields->{itype} }[$i], |
| 866 |
notforloan => @{ $fields->{notforloan} }[$i], |
| 867 |
uri => @{ $fields->{uri} }[$i], |
| 868 |
copynumber => @{ $fields->{copynumber} }[$i], |
| 869 |
price => @{ $fields->{price} }[$i], |
| 870 |
replacementprice => @{ $fields->{replacementprice} }[$i], |
| 871 |
itemcallnumber => @{ $fields->{itemcallnumber} }[$i], |
| 967 |
} |
872 |
} |
|
|
873 |
)->store; |
| 874 |
|
| 875 |
my %order_detail_hash = ( |
| 876 |
biblionumber => $fields->{biblionumber}, |
| 877 |
itemnumbers => ( $item->itemnumber ), |
| 878 |
basketno => $basket_id, |
| 879 |
quantity => 1, |
| 880 |
budget_id => @{ $fields->{budget_code} }[$i] |
| 881 |
|| $budget_id, |
| 882 |
currency => $vendor->listprice, |
| 883 |
); |
| 884 |
|
| 885 |
if ( @{ $fields->{price} }[$i] ) { |
| 886 |
$order_detail_hash{tax_rate_on_ordering} = $vendor->tax_rate; |
| 887 |
$order_detail_hash{tax_rate_on_receiving} = $vendor->tax_rate; |
| 888 |
my $order_discount = $fields->{c_discount} ? $fields->{c_discount} : $vendor->discount; |
| 889 |
$order_detail_hash{discount} = $order_discount; |
| 890 |
$order_detail_hash{rrp} = @{ $fields->{price} }[$i]; |
| 891 |
$order_detail_hash{ecost} = |
| 892 |
$order_discount ? @{ $fields->{price} }[$i] * ( 1 - $order_discount / 100 ) : @{ $fields->{price} }[$i]; |
| 893 |
$order_detail_hash{listprice} = $order_detail_hash{rrp} / $active_currency->rate; |
| 894 |
$order_detail_hash{unitprice} = $order_detail_hash{ecost}; |
| 895 |
} else { |
| 896 |
$order_detail_hash{listprice} = 0; |
| 968 |
} |
897 |
} |
|
|
898 |
$order_detail_hash{replacementprice} = @{ $fields->{replacementprice} }[$i] || 0; |
| 899 |
$order_detail_hash{uncertainprice} = 0 if $order_detail_hash{listprice}; |
| 900 |
|
| 901 |
push @order_line_details, \%order_detail_hash; |
| 902 |
|
| 969 |
} |
903 |
} |
| 970 |
$template->param( available_matchers => \@matchers ); |
904 |
return \@order_line_details; |
| 971 |
} |
905 |
} |
| 972 |
|
906 |
|
| 973 |
1; |
907 |
1; |