|
Lines 110-115
sub create_edi_order {
Link Here
|
| 110 |
)->single; |
110 |
)->single; |
| 111 |
} |
111 |
} |
| 112 |
|
112 |
|
|
|
113 |
unless ($ean_obj) { |
| 114 |
carp "No matching EAN found for $ean"; |
| 115 |
return; |
| 116 |
} |
| 117 |
|
| 113 |
my $dbh = C4::Context->dbh; |
118 |
my $dbh = C4::Context->dbh; |
| 114 |
my $arr_ref = $dbh->selectcol_arrayref( |
119 |
my $arr_ref = $dbh->selectcol_arrayref( |
| 115 |
'select id from edifact_messages where basketno = ? and message_type = \'QUOTE\'', |
120 |
'select id from edifact_messages where basketno = ? and message_type = \'QUOTE\'', |
|
Lines 290-296
sub process_invoice {
Link Here
|
| 290 |
if ( !$vendor_acct ) { |
295 |
if ( !$vendor_acct ) { |
| 291 |
$invoice_message->add_to_edifact_errors( |
296 |
$invoice_message->add_to_edifact_errors( |
| 292 |
{ |
297 |
{ |
| 293 |
section => '', |
298 |
section => "NAD+SU+" . $msg->supplier_ean, |
| 294 |
details => "Skipped invoice $invoicenumber with unmatched vendor san: $vendor_ean" |
299 |
details => "Skipped invoice $invoicenumber with unmatched vendor san: $vendor_ean" |
| 295 |
} |
300 |
} |
| 296 |
); |
301 |
); |
|
Lines 299-305
sub process_invoice {
Link Here
|
| 299 |
next; |
304 |
next; |
| 300 |
} |
305 |
} |
| 301 |
$invoice_message->edi_acct( $vendor_acct->id ); |
306 |
$invoice_message->edi_acct( $vendor_acct->id ); |
| 302 |
$logger->trace("Adding invoice:$invoicenumber"); |
307 |
$logger->trace("Adding invoice: $invoicenumber"); |
| 303 |
my $new_invoice = $schema->resultset('Aqinvoice')->create( |
308 |
my $new_invoice = $schema->resultset('Aqinvoice')->create( |
| 304 |
{ |
309 |
{ |
| 305 |
invoicenumber => $invoicenumber, |
310 |
invoicenumber => $invoicenumber, |
|
Lines 320-327
sub process_invoice {
Link Here
|
| 320 |
if ( !$ordernumber ) { |
325 |
if ( !$ordernumber ) { |
| 321 |
$invoice_message->add_to_edifact_errors( |
326 |
$invoice_message->add_to_edifact_errors( |
| 322 |
{ |
327 |
{ |
| 323 |
section => $line->line_item_number, |
328 |
section => join( "\n", map { $_->as_string } @{ $line->{segs} } ), |
| 324 |
details => "Message missing ordernumber" |
329 |
details => "Skipped invoice line " . $line->line_item_number . ", missing ordernumber" |
| 325 |
} |
330 |
} |
| 326 |
); |
331 |
); |
| 327 |
$logger->error("Skipping invoice line, no associated ordernumber"); |
332 |
$logger->error("Skipping invoice line, no associated ordernumber"); |
|
Lines 333-340
sub process_invoice {
Link Here
|
| 333 |
if ( !$order ) { |
338 |
if ( !$order ) { |
| 334 |
$invoice_message->add_to_edifact_errors( |
339 |
$invoice_message->add_to_edifact_errors( |
| 335 |
{ |
340 |
{ |
| 336 |
section => $line->line_item_number, |
341 |
section => join( "\n", map { $_->as_string } @{ $line->{segs} } ), |
| 337 |
details => "Koha order $ordernumber missing" |
342 |
details => "Skipped invoice line " |
|
|
343 |
. $line->line_item_number |
| 344 |
. ", cannot find order with ordernumber " |
| 345 |
. $ordernumber |
| 338 |
} |
346 |
} |
| 339 |
); |
347 |
); |
| 340 |
$logger->error("Skipping invoice line, no order found for $ordernumber, invoice:$invoicenumber"); |
348 |
$logger->error("Skipping invoice line, no order found for $ordernumber, invoice:$invoicenumber"); |
|
Lines 345-352
sub process_invoice {
Link Here
|
| 345 |
if ( !$bib ) { |
353 |
if ( !$bib ) { |
| 346 |
$invoice_message->add_to_edifact_errors( |
354 |
$invoice_message->add_to_edifact_errors( |
| 347 |
{ |
355 |
{ |
| 348 |
section => $line->line_item_number, |
356 |
section => join( "\n", map { $_->as_string } @{ $line->{segs} } ), |
| 349 |
details => "Koha biblio missing" |
357 |
details => "Skipped invoice line " |
|
|
358 |
. $line->line_item_number |
| 359 |
. ", cannot find biblio for ordernumber " |
| 360 |
. $ordernumber |
| 350 |
} |
361 |
} |
| 351 |
); |
362 |
); |
| 352 |
$logger->error( |
363 |
$logger->error( |
|
Lines 476-483
sub receipt_items {
Link Here
|
| 476 |
my $i = $ilink->itemnumber; |
487 |
my $i = $ilink->itemnumber; |
| 477 |
$invoice_message->add_to_edifact_errors( |
488 |
$invoice_message->add_to_edifact_errors( |
| 478 |
{ |
489 |
{ |
| 479 |
section => $inv_line->line_item_number, |
490 |
section => join( "\n", map { $_->as_string } @{ $inv_line->{segs} } ), |
| 480 |
details => "Cannot fine aqorder item" |
491 |
details => "Skipped invoice line " |
|
|
492 |
. $inv_line->line_item_number |
| 493 |
. ", Koha item with itemnumber " |
| 494 |
. $i |
| 495 |
. "is missing" |
| 481 |
} |
496 |
} |
| 482 |
); |
497 |
); |
| 483 |
$logger->warn("Cannot find aqorder item for $i: Order: $ordernumber"); |
498 |
$logger->warn("Cannot find aqorder item for $i: Order: $ordernumber"); |
|
Lines 520-527
sub receipt_items {
Link Here
|
| 520 |
if ( $rs->count > 0 ) { |
535 |
if ( $rs->count > 0 ) { |
| 521 |
$invoice_message->add_to_edifact_errors( |
536 |
$invoice_message->add_to_edifact_errors( |
| 522 |
{ |
537 |
{ |
| 523 |
section => $inv_line->line_item_number . " : " . $gir_occurrence, |
538 |
section => join( "\n", map { $_->as_string } @{ $inv_line->{segs} } ), |
| 524 |
details => "Duplicate barcode found $barcode" |
539 |
details => "Failed to assign barcode " |
|
|
540 |
. $barcode |
| 541 |
. "for invoice line " |
| 542 |
. $inv_line->line_item_number |
| 543 |
. ", duplicate found" |
| 525 |
} |
544 |
} |
| 526 |
); |
545 |
); |
| 527 |
$logger->warn("Barcode $barcode is a duplicate"); |
546 |
$logger->warn("Barcode $barcode is a duplicate"); |
|
Lines 548-555
sub receipt_items {
Link Here
|
| 548 |
} else { |
567 |
} else { |
| 549 |
$invoice_message->add_to_edifact_errors( |
568 |
$invoice_message->add_to_edifact_errors( |
| 550 |
{ |
569 |
{ |
| 551 |
section => $inv_line->line_item_number, |
570 |
section => join( "\n", map { $_->as_string } @{ $inv_line->{segs} } ), |
| 552 |
details => "Unmatched item at branch $branch" |
571 |
details => "No matching item found for invoice line " |
|
|
572 |
. $inv_line->line_item_number . ":" |
| 573 |
. $gir_occurrence |
| 574 |
. " at branch $branch" |
| 553 |
} |
575 |
} |
| 554 |
); |
576 |
); |
| 555 |
$logger->warn("Unmatched item at branch:$branch"); |
577 |
$logger->warn("Unmatched item at branch:$branch"); |
|
Lines 716-725
sub quote_item {
Link Here
|
| 716 |
details => "Failed to create basket" |
738 |
details => "Failed to create basket" |
| 717 |
} |
739 |
} |
| 718 |
); |
740 |
); |
| 719 |
$logger->error('Skipping order creation no valid basketno'); |
741 |
$logger->error('Skipped order creation no valid basketno'); |
| 720 |
return; |
742 |
return; |
| 721 |
} |
743 |
} |
| 722 |
$logger->trace( 'Checking db for matches with ', $item->item_number_id() ); |
744 |
$logger->trace( 'Checking db for matches with ' . $item->item_number_id() ); |
| 723 |
my $bib = _check_for_existing_bib( $item->item_number_id() ); |
745 |
my $bib = _check_for_existing_bib( $item->item_number_id() ); |
| 724 |
if ( !defined $bib ) { |
746 |
if ( !defined $bib ) { |
| 725 |
$bib = {}; |
747 |
$bib = {}; |
|
Lines 730-738
sub quote_item {
Link Here
|
| 730 |
|
752 |
|
| 731 |
( $bib->{biblionumber}, $bib->{biblioitemnumber} ) = |
753 |
( $bib->{biblionumber}, $bib->{biblioitemnumber} ) = |
| 732 |
AddBiblio( $bib_record, q{} ); |
754 |
AddBiblio( $bib_record, q{} ); |
| 733 |
$logger->trace("New biblio added $bib->{biblionumber}"); |
755 |
$logger->trace( "Added biblio: " . $bib->{biblionumber} ); |
| 734 |
} else { |
756 |
} else { |
| 735 |
$logger->trace("Match found: $bib->{biblionumber}"); |
757 |
$logger->trace( "Match found: " . $bib->{biblionumber} ); |
| 736 |
} |
758 |
} |
| 737 |
|
759 |
|
| 738 |
# Create an orderline |
760 |
# Create an orderline |
|
Lines 745-751
sub quote_item {
Link Here
|
| 745 |
if ( $gir_count != $order_quantity ) { |
767 |
if ( $gir_count != $order_quantity ) { |
| 746 |
$quote_message->add_to_edifact_errors( |
768 |
$quote_message->add_to_edifact_errors( |
| 747 |
{ |
769 |
{ |
| 748 |
section => "GIR", |
770 |
section => join( '\n', @{ $item->{GIR} } ), |
| 749 |
details => "Order for $order_quantity items, $gir_count segments present" |
771 |
details => "Order for $order_quantity items, $gir_count segments present" |
| 750 |
} |
772 |
} |
| 751 |
); |
773 |
); |
|
Lines 829-848
sub quote_item {
Link Here
|
| 829 |
if ( $item->quantity > 1 ) { |
851 |
if ( $item->quantity > 1 ) { |
| 830 |
$quote_message->add_to_edifact_errors( |
852 |
$quote_message->add_to_edifact_errors( |
| 831 |
{ |
853 |
{ |
| 832 |
section => "GIR", |
854 |
section => join( '\n', @{ $item->{GIR} } ), |
| 833 |
details => "Skipped GIR line with invalid budget: " . $item->girfield('fund_allocation') |
855 |
details => "Skipped GIR line with invalid budget: " . $item->girfield('fund_allocation') |
| 834 |
} |
856 |
} |
| 835 |
); |
857 |
); |
| 836 |
$logger->trace('girfield skipped for invalid budget'); |
858 |
$logger->trace( 'Skipping item with invalid budget: ' . $item->girfield('fund_allocation') ); |
| 837 |
$skip++; |
859 |
$skip++; |
| 838 |
} else { |
860 |
} else { |
| 839 |
$quote_message->add_to_edifact_errors( |
861 |
$quote_message->add_to_edifact_errors( |
| 840 |
{ |
862 |
{ |
| 841 |
section => "GIR", |
863 |
section => join( "\n", map { $_->as_string } @{ $item->{segs} } ), |
| 842 |
details => "Skipped orderline line with invalid budget: " . $item->girfield('fund_allocation') |
864 |
details => "Skipped orderline line with invalid budget: " . $item->girfield('fund_allocation') |
| 843 |
} |
865 |
} |
| 844 |
); |
866 |
); |
| 845 |
$logger->trace('orderline skipped for invalid budget'); |
867 |
$logger->trace( 'Skipping orderline with invalid budget: ' . $item->girfield('fund_allocation') ); |
| 846 |
return; |
868 |
return; |
| 847 |
} |
869 |
} |
| 848 |
} |
870 |
} |
|
Lines 876-882
sub quote_item {
Link Here
|
| 876 |
$item_hash->{biblioitemnumber} = $bib->{biblioitemnumber}; |
898 |
$item_hash->{biblioitemnumber} = $bib->{biblioitemnumber}; |
| 877 |
my $kitem = Koha::Item->new($item_hash)->store; |
899 |
my $kitem = Koha::Item->new($item_hash)->store; |
| 878 |
my $itemnumber = $kitem->itemnumber; |
900 |
my $itemnumber = $kitem->itemnumber; |
| 879 |
$logger->trace("Added item:$itemnumber"); |
901 |
$logger->trace( "Added item: " . $itemnumber ); |
| 880 |
$schema->resultset('AqordersItem')->create( |
902 |
$schema->resultset('AqordersItem')->create( |
| 881 |
{ |
903 |
{ |
| 882 |
ordernumber => $first_order->ordernumber, |
904 |
ordernumber => $first_order->ordernumber, |
|
Lines 893-904
sub quote_item {
Link Here
|
| 893 |
); |
915 |
); |
| 894 |
if ($rota) { |
916 |
if ($rota) { |
| 895 |
$rota->add_item($itemnumber); |
917 |
$rota->add_item($itemnumber); |
| 896 |
$logger->trace("Item added to rota $rota->id"); |
918 |
$logger->trace( "Item added to rota " . $rota->title ); |
| 897 |
} else { |
919 |
} else { |
| 898 |
$quote_message->add_to_edifact_errors( |
920 |
$quote_message->add_to_edifact_errors( |
| 899 |
{ |
921 |
{ |
| 900 |
section => "LRP", |
922 |
section => "$item->{GIR}->[0]", |
| 901 |
details => "No rota found for passed $lrp in orderline" |
923 |
details => "No rota found for passed LRP:$lrp in orderline" |
| 902 |
} |
924 |
} |
| 903 |
); |
925 |
); |
| 904 |
$logger->error("No rota found matching $lrp in orderline"); |
926 |
$logger->error("No rota found matching $lrp in orderline"); |
|
Lines 922-932
sub quote_item {
Link Here
|
| 922 |
my $bad_budget = $item->girfield( 'fund_allocation', $occurrence ); |
944 |
my $bad_budget = $item->girfield( 'fund_allocation', $occurrence ); |
| 923 |
$quote_message->add_to_edifact_errors( |
945 |
$quote_message->add_to_edifact_errors( |
| 924 |
{ |
946 |
{ |
| 925 |
section => "GIR", |
947 |
section => "$item->{GIR}->[$occurrence]", |
| 926 |
details => "Skipped GIR line with invalid budget: $bad_budget" |
948 |
details => "Invalid budget $bad_budget found" |
| 927 |
} |
949 |
} |
| 928 |
); |
950 |
); |
| 929 |
$logger->trace("girfield skipped for invalid budget:$bad_budget"); |
951 |
$logger->trace( "Skipping item with invalid budget: " . $bad_budget ); |
| 930 |
++$occurrence; ## lets look at the next one not this one again |
952 |
++$occurrence; ## lets look at the next one not this one again |
| 931 |
next; |
953 |
next; |
| 932 |
} |
954 |
} |
|
Lines 1009-1016
sub quote_item {
Link Here
|
| 1009 |
} else { |
1031 |
} else { |
| 1010 |
$quote_message->add_to_edifact_errors( |
1032 |
$quote_message->add_to_edifact_errors( |
| 1011 |
{ |
1033 |
{ |
| 1012 |
section => "LRP", |
1034 |
section => "$item->{GIR}->[$occurrence]", |
| 1013 |
details => "No rota found for passed $lrp in orderline" |
1035 |
details => "No rota found for passed LRP:$lrp in orderline" |
| 1014 |
} |
1036 |
} |
| 1015 |
); |
1037 |
); |
| 1016 |
$logger->error("No rota found matching $lrp in orderline"); |
1038 |
$logger->error("No rota found matching $lrp in orderline"); |
|
Lines 1076-1083
sub quote_item {
Link Here
|
| 1076 |
} else { |
1098 |
} else { |
| 1077 |
$quote_message->add_to_edifact_errors( |
1099 |
$quote_message->add_to_edifact_errors( |
| 1078 |
{ |
1100 |
{ |
| 1079 |
section => "LRP", |
1101 |
section => "$item->{GIR}->[$occurrence]", |
| 1080 |
details => "No rota found for passed $lrp in orderline" |
1102 |
details => "No rota found for passed LRP:$lrp in orderline" |
| 1081 |
} |
1103 |
} |
| 1082 |
); |
1104 |
); |
| 1083 |
$logger->error("No rota found matching $lrp in orderline"); |
1105 |
$logger->error("No rota found matching $lrp in orderline"); |