|
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 292-298
sub process_invoice {
Link Here
|
| 292 |
if ( !$vendor_acct ) { |
297 |
if ( !$vendor_acct ) { |
| 293 |
$invoice_message->add_to_edifact_errors( |
298 |
$invoice_message->add_to_edifact_errors( |
| 294 |
{ |
299 |
{ |
| 295 |
section => '', |
300 |
section => "NAD+SU+" . $msg->supplier_ean, |
| 296 |
details => "Skipped invoice $invoicenumber with unmatched vendor san: $vendor_ean" |
301 |
details => "Skipped invoice $invoicenumber with unmatched vendor san: $vendor_ean" |
| 297 |
} |
302 |
} |
| 298 |
); |
303 |
); |
|
Lines 300-306
sub process_invoice {
Link Here
|
| 300 |
next; |
305 |
next; |
| 301 |
} |
306 |
} |
| 302 |
$invoice_message->edi_acct( $vendor_acct->id ); |
307 |
$invoice_message->edi_acct( $vendor_acct->id ); |
| 303 |
$logger->trace("Adding invoice:$invoicenumber"); |
308 |
$logger->trace("Adding invoice: $invoicenumber"); |
| 304 |
my $new_invoice = $schema->resultset('Aqinvoice')->create( |
309 |
my $new_invoice = $schema->resultset('Aqinvoice')->create( |
| 305 |
{ |
310 |
{ |
| 306 |
invoicenumber => $invoicenumber, |
311 |
invoicenumber => $invoicenumber, |
|
Lines 321-328
sub process_invoice {
Link Here
|
| 321 |
if ( !$ordernumber ) { |
326 |
if ( !$ordernumber ) { |
| 322 |
$invoice_message->add_to_edifact_errors( |
327 |
$invoice_message->add_to_edifact_errors( |
| 323 |
{ |
328 |
{ |
| 324 |
section => $line->line_item_number, |
329 |
section => join("\n", map { $_->as_string } @{$line->{segs}}), |
| 325 |
details => "Message missing ordernumber" |
330 |
details => "Skipped invoice line " . $line->line_item_number . ", missing ordernumber" |
| 326 |
} |
331 |
} |
| 327 |
); |
332 |
); |
| 328 |
$logger->error("Skipping invoice line, no associated ordernumber"); |
333 |
$logger->error("Skipping invoice line, no associated ordernumber"); |
|
Lines 334-341
sub process_invoice {
Link Here
|
| 334 |
if ( !$order ) { |
339 |
if ( !$order ) { |
| 335 |
$invoice_message->add_to_edifact_errors( |
340 |
$invoice_message->add_to_edifact_errors( |
| 336 |
{ |
341 |
{ |
| 337 |
section => $line->line_item_number, |
342 |
section => join( "\n", map { $_->as_string } @{ $line->{segs} } ), |
| 338 |
details => "Koha order $ordernumber missing" |
343 |
details => "Skipped invoice line " |
|
|
344 |
. $line->line_item_number |
| 345 |
. ", cannot find order with ordernumber " |
| 346 |
. $ordernumber |
| 339 |
} |
347 |
} |
| 340 |
); |
348 |
); |
| 341 |
$logger->error("Skipping invoice line, no order found for $ordernumber, invoice:$invoicenumber"); |
349 |
$logger->error("Skipping invoice line, no order found for $ordernumber, invoice:$invoicenumber"); |
|
Lines 346-353
sub process_invoice {
Link Here
|
| 346 |
if ( !$bib ) { |
354 |
if ( !$bib ) { |
| 347 |
$invoice_message->add_to_edifact_errors( |
355 |
$invoice_message->add_to_edifact_errors( |
| 348 |
{ |
356 |
{ |
| 349 |
section => $line->line_item_number, |
357 |
section => join( "\n", map { $_->as_string } @{ $line->{segs} } ), |
| 350 |
details => "Koha biblio missing" |
358 |
details => "Skipped invoice line " |
|
|
359 |
. $line->line_item_number |
| 360 |
. ", cannot find biblio for ordernumber " |
| 361 |
. $ordernumber |
| 351 |
} |
362 |
} |
| 352 |
); |
363 |
); |
| 353 |
$logger->error( |
364 |
$logger->error( |
|
Lines 477-484
sub receipt_items {
Link Here
|
| 477 |
my $i = $ilink->itemnumber; |
488 |
my $i = $ilink->itemnumber; |
| 478 |
$invoice_message->add_to_edifact_errors( |
489 |
$invoice_message->add_to_edifact_errors( |
| 479 |
{ |
490 |
{ |
| 480 |
section => $inv_line->line_item_number, |
491 |
section => join( "\n", map { $_->as_string } @{ $inv_line->{segs} } ), |
| 481 |
details => "Cannot fine aqorder item" |
492 |
details => "Skipped invoice line " |
|
|
493 |
. $inv_line->line_item_number |
| 494 |
. ", Koha item with itemnumber " |
| 495 |
. $i |
| 496 |
. "is missing" |
| 482 |
} |
497 |
} |
| 483 |
); |
498 |
); |
| 484 |
$logger->warn( |
499 |
$logger->warn( |
|
Lines 522-529
sub receipt_items {
Link Here
|
| 522 |
if ( $rs->count > 0 ) { |
537 |
if ( $rs->count > 0 ) { |
| 523 |
$invoice_message->add_to_edifact_errors( |
538 |
$invoice_message->add_to_edifact_errors( |
| 524 |
{ |
539 |
{ |
| 525 |
section => $inv_line->line_item_number . " : " . $gir_occurrence, |
540 |
section => join( "\n", map { $_->as_string } @{ $inv_line->{segs} } ), |
| 526 |
details => "Duplicate barcode found $barcode" |
541 |
details => "Failed to assign barcode " |
|
|
542 |
. $barcode |
| 543 |
. "for invoice line " |
| 544 |
. $inv_line->line_item_number |
| 545 |
. ", duplicate found" |
| 527 |
} |
546 |
} |
| 528 |
); |
547 |
); |
| 529 |
$logger->warn("Barcode $barcode is a duplicate"); |
548 |
$logger->warn("Barcode $barcode is a duplicate"); |
|
Lines 552-559
sub receipt_items {
Link Here
|
| 552 |
else { |
571 |
else { |
| 553 |
$invoice_message->add_to_edifact_errors( |
572 |
$invoice_message->add_to_edifact_errors( |
| 554 |
{ |
573 |
{ |
| 555 |
section => $inv_line->line_item_number, |
574 |
section => join("\n", map { $_->as_string } @{$inv_line->{segs}}), |
| 556 |
details => "Unmatched item at branch $branch" |
575 |
details => "No matching item found for invoice line " |
|
|
576 |
. $inv_line->line_item_number . ":" |
| 577 |
. $gir_occurrence |
| 578 |
. " at branch $branch" |
| 557 |
} |
579 |
} |
| 558 |
); |
580 |
); |
| 559 |
$logger->warn("Unmatched item at branch:$branch"); |
581 |
$logger->warn("Unmatched item at branch:$branch"); |
|
Lines 722-731
sub quote_item {
Link Here
|
| 722 |
details => "Failed to create basket" |
744 |
details => "Failed to create basket" |
| 723 |
} |
745 |
} |
| 724 |
); |
746 |
); |
| 725 |
$logger->error('Skipping order creation no valid basketno'); |
747 |
$logger->error('Skipped order creation no valid basketno'); |
| 726 |
return; |
748 |
return; |
| 727 |
} |
749 |
} |
| 728 |
$logger->trace( 'Checking db for matches with ', $item->item_number_id() ); |
750 |
$logger->trace( 'Checking db for matches with ' . $item->item_number_id() ); |
| 729 |
my $bib = _check_for_existing_bib( $item->item_number_id() ); |
751 |
my $bib = _check_for_existing_bib( $item->item_number_id() ); |
| 730 |
if ( !defined $bib ) { |
752 |
if ( !defined $bib ) { |
| 731 |
$bib = {}; |
753 |
$bib = {}; |
|
Lines 736-745
sub quote_item {
Link Here
|
| 736 |
|
758 |
|
| 737 |
( $bib->{biblionumber}, $bib->{biblioitemnumber} ) = |
759 |
( $bib->{biblionumber}, $bib->{biblioitemnumber} ) = |
| 738 |
AddBiblio( $bib_record, q{} ); |
760 |
AddBiblio( $bib_record, q{} ); |
| 739 |
$logger->trace("New biblio added $bib->{biblionumber}"); |
761 |
$logger->trace("Added biblio: ". $bib->{biblionumber}); |
| 740 |
} |
762 |
} |
| 741 |
else { |
763 |
else { |
| 742 |
$logger->trace("Match found: $bib->{biblionumber}"); |
764 |
$logger->trace("Match found: " .$bib->{biblionumber}); |
| 743 |
} |
765 |
} |
| 744 |
|
766 |
|
| 745 |
# Create an orderline |
767 |
# Create an orderline |
|
Lines 752-758
sub quote_item {
Link Here
|
| 752 |
if ( $gir_count != $order_quantity ) { |
774 |
if ( $gir_count != $order_quantity ) { |
| 753 |
$quote_message->add_to_edifact_errors( |
775 |
$quote_message->add_to_edifact_errors( |
| 754 |
{ |
776 |
{ |
| 755 |
section => "GIR", |
777 |
section => join('\n', @{$item->{GIR}}), |
| 756 |
details => "Order for $order_quantity items, $gir_count segments present" |
778 |
details => "Order for $order_quantity items, $gir_count segments present" |
| 757 |
} |
779 |
} |
| 758 |
); |
780 |
); |
|
Lines 838-857
sub quote_item {
Link Here
|
| 838 |
if ( $item->quantity > 1 ) { |
860 |
if ( $item->quantity > 1 ) { |
| 839 |
$quote_message->add_to_edifact_errors( |
861 |
$quote_message->add_to_edifact_errors( |
| 840 |
{ |
862 |
{ |
| 841 |
section => "GIR", |
863 |
section => join( '\n', @{ $item->{GIR} } ), |
| 842 |
details => "Skipped GIR line with invalid budget: " . $item->girfield('fund_allocation') |
864 |
details => "Skipped GIR line with invalid budget: " . $item->girfield('fund_allocation') |
| 843 |
} |
865 |
} |
| 844 |
); |
866 |
); |
| 845 |
$logger->trace('girfield skipped for invalid budget'); |
867 |
$logger->trace( 'Skipping item with invalid budget: ' . $item->girfield('fund_allocation') ); |
| 846 |
$skip++; |
868 |
$skip++; |
| 847 |
} else { |
869 |
} else { |
| 848 |
$quote_message->add_to_edifact_errors( |
870 |
$quote_message->add_to_edifact_errors( |
| 849 |
{ |
871 |
{ |
| 850 |
section => "GIR", |
872 |
section => join( "\n", map { $_->as_string } @{ $item->{segs} } ), |
| 851 |
details => "Skipped orderline line with invalid budget: " . $item->girfield('fund_allocation') |
873 |
details => "Skipped orderline line with invalid budget: " . $item->girfield('fund_allocation') |
| 852 |
} |
874 |
} |
| 853 |
); |
875 |
); |
| 854 |
$logger->trace('orderline skipped for invalid budget'); |
876 |
$logger->trace( 'Skipping orderline with invalid budget: ' . $item->girfield('fund_allocation') ); |
| 855 |
return; |
877 |
return; |
| 856 |
} |
878 |
} |
| 857 |
} |
879 |
} |
|
Lines 885-891
sub quote_item {
Link Here
|
| 885 |
$item_hash->{biblioitemnumber} = $bib->{biblioitemnumber}; |
907 |
$item_hash->{biblioitemnumber} = $bib->{biblioitemnumber}; |
| 886 |
my $kitem = Koha::Item->new( $item_hash )->store; |
908 |
my $kitem = Koha::Item->new( $item_hash )->store; |
| 887 |
my $itemnumber = $kitem->itemnumber; |
909 |
my $itemnumber = $kitem->itemnumber; |
| 888 |
$logger->trace("Added item:$itemnumber"); |
910 |
$logger->trace("Added item: ". $itemnumber); |
| 889 |
$schema->resultset('AqordersItem')->create( |
911 |
$schema->resultset('AqordersItem')->create( |
| 890 |
{ |
912 |
{ |
| 891 |
ordernumber => $first_order->ordernumber, |
913 |
ordernumber => $first_order->ordernumber, |
|
Lines 902-913
sub quote_item {
Link Here
|
| 902 |
); |
924 |
); |
| 903 |
if ($rota) { |
925 |
if ($rota) { |
| 904 |
$rota->add_item($itemnumber); |
926 |
$rota->add_item($itemnumber); |
| 905 |
$logger->trace("Item added to rota $rota->id"); |
927 |
$logger->trace("Item added to rota " . $rota->title); |
| 906 |
} else { |
928 |
} else { |
| 907 |
$quote_message->add_to_edifact_errors( |
929 |
$quote_message->add_to_edifact_errors( |
| 908 |
{ |
930 |
{ |
| 909 |
section => "LRP", |
931 |
section => "$item->{GIR}->[0]", |
| 910 |
details => "No rota found for passed $lrp in orderline" |
932 |
details => "No rota found for passed LRP:$lrp in orderline" |
| 911 |
} |
933 |
} |
| 912 |
); |
934 |
); |
| 913 |
$logger->error("No rota found matching $lrp in orderline"); |
935 |
$logger->error("No rota found matching $lrp in orderline"); |
|
Lines 930-941
sub quote_item {
Link Here
|
| 930 |
$item->girfield( 'fund_allocation', $occurrence ); |
952 |
$item->girfield( 'fund_allocation', $occurrence ); |
| 931 |
$quote_message->add_to_edifact_errors( |
953 |
$quote_message->add_to_edifact_errors( |
| 932 |
{ |
954 |
{ |
| 933 |
section => "GIR", |
955 |
section => "$item->{GIR}->[$occurrence]", |
| 934 |
details => "Skipped GIR line with invalid budget: $bad_budget" |
956 |
details => "Invalid budget $bad_budget found" |
| 935 |
} |
957 |
} |
| 936 |
); |
958 |
); |
| 937 |
$logger->trace( |
959 |
$logger->trace( |
| 938 |
"girfield skipped for invalid budget:$bad_budget"); |
960 |
"Skipping item with invalid budget: " . $bad_budget); |
| 939 |
++$occurrence; ## lets look at the next one not this one again |
961 |
++$occurrence; ## lets look at the next one not this one again |
| 940 |
next; |
962 |
next; |
| 941 |
} |
963 |
} |
|
Lines 1025-1032
sub quote_item {
Link Here
|
| 1025 |
else { |
1047 |
else { |
| 1026 |
$quote_message->add_to_edifact_errors( |
1048 |
$quote_message->add_to_edifact_errors( |
| 1027 |
{ |
1049 |
{ |
| 1028 |
section => "LRP", |
1050 |
section => "$item->{GIR}->[$occurrence]", |
| 1029 |
details => "No rota found for passed $lrp in orderline" |
1051 |
details => "No rota found for passed LRP:$lrp in orderline" |
| 1030 |
} |
1052 |
} |
| 1031 |
); |
1053 |
); |
| 1032 |
$logger->error( |
1054 |
$logger->error( |
|
Lines 1101-1108
sub quote_item {
Link Here
|
| 1101 |
else { |
1123 |
else { |
| 1102 |
$quote_message->add_to_edifact_errors( |
1124 |
$quote_message->add_to_edifact_errors( |
| 1103 |
{ |
1125 |
{ |
| 1104 |
section => "LRP", |
1126 |
section => "$item->{GIR}->[$occurrence]", |
| 1105 |
details => "No rota found for passed $lrp in orderline" |
1127 |
details => "No rota found for passed LRP:$lrp in orderline" |
| 1106 |
} |
1128 |
} |
| 1107 |
); |
1129 |
); |
| 1108 |
$logger->error( |
1130 |
$logger->error( |