View | Details | Raw Unified | Return to bug 20780
Collapse All | Expand All

(-)a/Koha/EDI.pm (-2 / +30 lines)
Lines 30-36 use Koha::Database; Link Here
30
use C4::Acquisition qw( NewBasket CloseBasket ModOrder);
30
use C4::Acquisition qw( NewBasket CloseBasket ModOrder);
31
use C4::Suggestions qw( ModSuggestion );
31
use C4::Suggestions qw( ModSuggestion );
32
use C4::Items qw(AddItem);
32
use C4::Items qw(AddItem);
33
use C4::Biblio qw( AddBiblio TransformKohaToMarc GetMarcBiblio );
33
use C4::Biblio qw( AddBiblio TransformKohaToMarc GetMarcBiblio GetFrameworkCode GetMarcFromKohaField );
34
use Koha::Edifact::Order;
34
use Koha::Edifact::Order;
35
use Koha::Edifact;
35
use Koha::Edifact;
36
use Log::Log4perl;
36
use Log::Log4perl;
Lines 388-393 sub receipt_items { Link Here
388
        }
388
        }
389
        push @{ $branch_map{$b} }, $item;
389
        push @{ $branch_map{$b} }, $item;
390
    }
390
    }
391
392
    # Handling for 'AcqItemSetSubfieldsWhenReceived'
393
    my @affects;
394
    my $biblionumber;
395
    my $itemfield;
396
    if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
397
        @affects = split q{\|},
398
          C4::Context->preference("AcqItemSetSubfieldsWhenReceived");
399
        if (@affects) {
400
            $biblionumber = $schema->resultset('Aqorder')->find($ordernumber)
401
              ->biblionumber->biblionumber;
402
            my $frameworkcode = GetFrameworkCode($biblionumber);
403
            ($itemfield) = GetMarcFromKohaField( 'items.itemnumber',
404
                $frameworkcode );
405
        }
406
    }
407
391
    my $gir_occurrence = 0;
408
    my $gir_occurrence = 0;
392
    while ( $gir_occurrence < $quantity ) {
409
    while ( $gir_occurrence < $quantity ) {
393
        my $branch = $inv_line->girfield( 'branch', $gir_occurrence );
410
        my $branch = $inv_line->girfield( 'branch', $gir_occurrence );
Lines 410-415 sub receipt_items { Link Here
410
                }
427
                }
411
            }
428
            }
412
429
430
            # Handling for 'AcqItemSetSubfieldsWhenReceived'
431
            if (@affects) {
432
                my $item_marc = C4::Items::GetMarcItem( $biblionumber, $item->itemnumber );
433
                for my $affect (@affects) {
434
                    my ( $sf, $v ) = split q{=}, $affect, 2;
435
                    foreach ( $item_marc->field($itemfield) ) {
436
                        $_->update( $sf => $v );
437
                    }
438
                }
439
                C4::Items::ModItemFromMarc( $item_marc, $biblionumber, $item->itemnumber );
440
            }
441
413
            $item->update;
442
            $item->update;
414
        }
443
        }
415
        else {
444
        else {
416
- 

Return to bug 20780