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 378-383 sub receipt_items { Link Here
378
        }
378
        }
379
        push @{ $branch_map{$b} }, $item;
379
        push @{ $branch_map{$b} }, $item;
380
    }
380
    }
381
382
    # Handling for 'AcqItemSetSubfieldsWhenReceived'
383
    my @affects;
384
    my $biblionumber;
385
    my $itemfield;
386
    if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
387
        @affects = split q{\|},
388
          C4::Context->preference("AcqItemSetSubfieldsWhenReceived");
389
        if (@affects) {
390
            $biblionumber = $schema->resultset('Aqorder')->find($ordernumber)
391
              ->biblionumber->biblionumber;
392
            my $frameworkcode = GetFrameworkCode($biblionumber);
393
            ($itemfield) = GetMarcFromKohaField( 'items.itemnumber',
394
                $frameworkcode );
395
        }
396
    }
397
381
    my $gir_occurrence = 0;
398
    my $gir_occurrence = 0;
382
    while ( $gir_occurrence < $quantity ) {
399
    while ( $gir_occurrence < $quantity ) {
383
        my $branch = $inv_line->girfield( 'branch', $gir_occurrence );
400
        my $branch = $inv_line->girfield( 'branch', $gir_occurrence );
Lines 400-405 sub receipt_items { Link Here
400
                }
417
                }
401
            }
418
            }
402
419
420
            # Handling for 'AcqItemSetSubfieldsWhenReceived'
421
            if (@affects) {
422
                my $item_marc = C4::Items::GetMarcItem( $biblionumber, $item->itemnumber );
423
                for my $affect (@affects) {
424
                    my ( $sf, $v ) = split q{=}, $affect, 2;
425
                    foreach ( $item_marc->field($itemfield) ) {
426
                        $_->update( $sf => $v );
427
                    }
428
                }
429
                C4::Items::ModItemFromMarc( $item_marc, $biblionumber, $item->itemnumber );
430
            }
431
403
            $item->update;
432
            $item->update;
404
        }
433
        }
405
        else {
434
        else {
406
- 

Return to bug 20780