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

(-)a/t/db_dependent/Koha/MarcOrder.t (-99 / +228 lines)
Lines 243-249 subtest 'add_biblio_from_import_record()' => sub { Link Here
243
};
243
};
244
244
245
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
245
subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub {
246
    plan tests => 6;
246
    plan tests => 2;
247
247
248
    $schema->storage->txn_begin;
248
    $schema->storage->txn_begin;
249
249
Lines 337-441 subtest 'add_items_from_import_record() - addorderiso2709.pl' => sub { Link Here
337
        }
337
        }
338
    );
338
    );
339
339
340
    my $client_item_fields = {
340
    subtest "Using MarcItemFieldsToOrder" => sub {
341
        'notforloans' => [
341
        plan tests => 6;
342
            '',
342
343
        ],
343
        my $client_item_fields = {
344
        'c_budget_id'       => 2,
344
            'notforloans' => [
345
        'replacementprices' => [
345
                '',
346
            '0.00',
346
            ],
347
        ],
347
            'c_budget_id'       => 2,
348
        'uris' => [
348
            'replacementprices' => [
349
            '',
349
                '0.00',
350
        ],
350
            ],
351
        'c_replacement_price' => '0.00',
351
            'uris' => [
352
        'public_notes'        => [''],
352
                '',
353
        'itemcallnumbers'     => [
353
            ],
354
            '',
354
            'c_replacement_price' => '0.00',
355
        ],
355
            'public_notes'        => [''],
356
        'budget_codes' => [
356
            'itemcallnumbers'     => [
357
            '',
357
                '',
358
        ],
358
            ],
359
        'nonpublic_notes' => [
359
            'budget_codes' => [
360
            '',
360
                '',
361
        ],
361
            ],
362
        'homebranches' => [
362
            'nonpublic_notes' => [
363
            $branchcode,
363
                '',
364
            $branchcode
364
            ],
365
        ],
365
            'homebranches' => [
366
        'copynos' => [
366
                $branchcode,
367
            '',
367
                $branchcode
368
        ],
368
            ],
369
        'holdingbranches' => [
369
            'copynos' => [
370
            $branchcode,
370
                '',
371
            $branchcode
371
            ],
372
        ],
372
            'holdingbranches' => [
373
        'ccodes' => [
373
                $branchcode,
374
            '',
374
                $branchcode
375
        ],
375
            ],
376
        'locs' => [
376
            'ccodes' => [
377
            '',
377
                '',
378
            ''
378
            ],
379
        ],
379
            'locs' => [
380
        'itemprices' => [
380
                '',
381
            '10.00',
381
                ''
382
        ],
382
            ],
383
        'c_discount' => '',
383
            'itemprices' => [
384
        'c_price'    => '0.00',
384
                '10.00',
385
        'c_sort2'    => '',
385
            ],
386
        'c_sort1'    => '',
386
            'c_discount' => '',
387
        'c_quantity' => '1',
387
            'c_price'    => '0.00',
388
        'itypes'     => [
388
            'c_sort2'    => '',
389
            'BK',
389
            'c_sort1'    => '',
390
        ],
390
            'c_quantity' => '1',
391
        'coded_location_qualifiers' => [],
391
            'itypes'     => [
392
        'barcodes'                  => [],
392
                'BK',
393
        'enumchrons'                => []
393
            ],
394
            'coded_location_qualifiers' => [],
395
            'barcodes'                  => [],
396
            'enumchrons'                => []
397
        };
398
        my $itemnumbers = Koha::MarcOrder::add_items_from_import_record(
399
            {
400
                record_result      => $result->{record_result},
401
                basket_id          => $basket->basketno,
402
                vendor             => $bookseller,
403
                budget_id          => $budgetid,
404
                agent              => 'client',
405
                client_item_fields => $client_item_fields,
406
            }
407
        );
408
409
        my $orders =
410
            Koha::Acquisition::Orders->search( { biblionumber => $result->{record_result}->{biblionumber} } )
411
            ->unblessed;
412
413
        is(
414
            @{$orders}[0]->{rrp} + 0, '10',
415
            "Price has been read correctly"
416
        );
417
418
        my $active_currency = Koha::Acquisition::Currencies->get_active;
419
        is(
420
            sprintf( "%.6f", @{$orders}[0]->{listprice} + 0 ), sprintf( "%.6f", 10 / $active_currency->rate + 0 ),
421
            "Listprice has been created successfully"
422
        );
423
        is(
424
            @{$orders}[0]->{quantity}, 1,
425
            "Quantity has been read correctly"
426
        );
427
        is(
428
            @{$orders}[0]->{budget_id}, $budgetid,
429
            "Budget code has been read correctly"
430
        );
431
432
        my $new_item = Koha::Items->find( ${$itemnumbers}[0] );
433
434
        isnt(
435
            $new_item, undef,
436
            'Item was successfully created'
437
        );
438
        is(
439
            $new_item->price, '10.00',
440
            'Item values mapped correctly'
441
        );
394
    };
442
    };
395
443
396
    my $itemnumbers = Koha::MarcOrder::add_items_from_import_record(
444
    subtest "Using MarcFieldsToOrder only" => sub {
397
        {
445
        plan tests => 9;
398
            record_result      => $result->{record_result},
446
399
            basket_id          => $basket->basketno,
447
        my $client_item_fields = {
400
            vendor             => $bookseller,
448
            'tags' => [
401
            budget_id          => $budgetid,
449
                '952',
402
            agent              => 'client',
450
                '952',
403
            client_item_fields => $client_item_fields,
451
                '952',
404
        }
452
                '952',
405
    );
453
            ],
406
454
            'subfields' => [
407
    my $orders =
455
                'a',
408
        Koha::Acquisition::Orders->search( { biblionumber => $result->{record_result}->{biblionumber} } )->unblessed;
456
                'b',
409
457
                'g',
410
    is(
458
                'y'
411
        @{$orders}[0]->{rrp} + 0, '10',
459
            ],
412
        "Price has been read correctly"
460
            field_values => [
413
    );
461
                $branchcode,
414
462
                $branchcode,
415
    my $active_currency = Koha::Acquisition::Currencies->get_active;
463
                "10.00",
416
    is(
464
                'BK'
417
        sprintf( "%.6f", @{$orders}[0]->{listprice} + 0 ), sprintf( "%.6f", 10 / $active_currency->rate + 0 ),
465
            ],
418
        "Listprice has been created successfully"
466
            'notforloans' => [
419
    );
467
                '',
420
    is(
468
            ],
421
        @{$orders}[0]->{quantity}, 1,
469
            'c_budget_id'       => 2,
422
        "Quantity has been read correctly"
470
            'replacementprices' => [
423
    );
471
                '0.00',
424
    is(
472
            ],
425
        @{$orders}[0]->{budget_id}, $budgetid,
473
            'uris' => [
426
        "Budget code has been read correctly"
474
                '',
427
    );
475
            ],
428
476
            'c_replacement_price' => '0.00',
429
    my $new_item = Koha::Items->find( ${$itemnumbers}[0] );
477
            'public_notes'        => [''],
430
478
            'itemcallnumbers'     => [
431
    isnt(
479
                '',
432
        $new_item, undef,
480
            ],
433
        'Item was successfully created'
481
            'budget_codes' => [
434
    );
482
                '',
435
    is(
483
            ],
436
        $new_item->price, '10.00',
484
            'nonpublic_notes' => [
437
        'Item values mapped correctly'
485
                '',
438
    );
486
            ],
487
            'homebranches' => [],
488
            'copynos'      => [
489
                '',
490
            ],
491
            'holdingbranches' => [],
492
            'ccodes'          => [
493
                '',
494
            ],
495
            'locs' => [
496
                '',
497
                ''
498
            ],
499
            'itemprices' => [
500
                '10.00',
501
            ],
502
            'c_discount'                => '',
503
            'c_price'                   => '0.00',
504
            'c_sort2'                   => '',
505
            'c_sort1'                   => '',
506
            'c_quantity'                => '1',
507
            'itypes'                    => [],
508
            'coded_location_qualifiers' => [],
509
            'barcodes'                  => [],
510
            'enumchrons'                => []
511
        };
512
        my $itemnumbers = Koha::MarcOrder::add_items_from_import_record(
513
            {
514
                record_result      => $result->{record_result},
515
                basket_id          => $basket->basketno,
516
                vendor             => $bookseller,
517
                budget_id          => $budgetid,
518
                agent              => 'client',
519
                client_item_fields => $client_item_fields,
520
            }
521
        );
522
523
        my $orders =
524
            Koha::Acquisition::Orders->search( { biblionumber => $result->{record_result}->{biblionumber} } )
525
            ->unblessed;
526
527
        is(
528
            @{$orders}[0]->{rrp} + 0, '10',
529
            "Price has been read correctly"
530
        );
531
532
        my $active_currency = Koha::Acquisition::Currencies->get_active;
533
        is(
534
            sprintf( "%.6f", @{$orders}[0]->{listprice} + 0 ), sprintf( "%.6f", 10 / $active_currency->rate + 0 ),
535
            "Listprice has been created successfully"
536
        );
537
        is(
538
            @{$orders}[0]->{quantity}, 1,
539
            "Quantity has been read correctly"
540
        );
541
        is(
542
            @{$orders}[0]->{budget_id}, $budgetid,
543
            "Budget code has been read correctly"
544
        );
545
546
        my $new_item = Koha::Items->find( ${$itemnumbers}[0] );
547
548
        isnt(
549
            $new_item, undef,
550
            'Item was successfully created'
551
        );
552
        is(
553
            $new_item->price, '10.00',
554
            'Item value for price mapped correctly'
555
        );
556
        is(
557
            $new_item->homebranch, $branchcode,
558
            'Item value for homebranch mapped correctly'
559
        );
560
        is(
561
            $new_item->holdingbranch, $branchcode,
562
            'Item value for holdingbranch mapped correctly'
563
        );
564
        is(
565
            $new_item->itype, 'BK',
566
            'Item value for itemtype mapped correctly'
567
        );
568
    };
439
569
440
    $schema->storage->txn_rollback;
570
    $schema->storage->txn_rollback;
441
};
571
};
442
- 

Return to bug 39282