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

(-)a/C4/Acquisition.pm (-8 / +6 lines)
Lines 1429-1438 sub ModReceiveOrder { Link Here
1429
            $query .= q|, order_internalnote = ?|;
1429
            $query .= q|, order_internalnote = ?|;
1430
            push @params, $order->{order_internalnote};
1430
            push @params, $order->{order_internalnote};
1431
        }
1431
        }
1432
        if ( defined $order->{invoice_unitprice} ) {
1432
1433
            $query .= q|, invoice_unitprice = ?, invoice_currency = ?|;
1433
        $query .= q|, invoice_unitprice = ?, invoice_currency = ?|;
1434
            push @params, $order->{invoice_unitprice}, $order->{invoice_currency};
1434
        push @params, $order->{invoice_unitprice}, $order->{invoice_currency};
1435
        }
1435
1436
        $query .= q|
1436
        $query .= q|
1437
            WHERE ordernumber = ?
1437
            WHERE ordernumber = ?
1438
        |;
1438
        |;
Lines 1491-1497 sub ModReceiveOrder { Link Here
1491
1491
1492
        $query .= q|
1492
        $query .= q|
1493
            , invoice_unitprice = ?, invoice_currency = ?
1493
            , invoice_unitprice = ?, invoice_currency = ?
1494
        | if defined $order->{invoice_unitprice};
1494
        |;
1495
1495
1496
        $query .= q| where biblionumber=? and ordernumber=?|;
1496
        $query .= q| where biblionumber=? and ordernumber=?|;
1497
1497
Lines 1518-1526 sub ModReceiveOrder { Link Here
1518
            push @params, $order->{order_internalnote};
1518
            push @params, $order->{order_internalnote};
1519
        }
1519
        }
1520
1520
1521
        if ( defined $order->{invoice_unitprice} ) {
1521
        push @params, $order->{invoice_unitprice}, $order->{invoice_currency};
1522
            push @params, $order->{invoice_unitprice}, $order->{invoice_currency};
1523
        }
1524
1522
1525
        push @params, ( $biblionumber, $order->{ordernumber} );
1523
        push @params, ( $biblionumber, $order->{ordernumber} );
1526
1524
(-)a/acqui/finishreceive.pl (-2 / +5 lines)
Lines 107-118 if ($quantityrec > $origquantityrec ) { Link Here
107
            replacementprice      => $replacementprice,
107
            replacementprice      => $replacementprice,
108
            unitprice             => $unitprice,
108
            unitprice             => $unitprice,
109
            (
109
            (
110
                defined $invoice_unitprice && $invoice_unitprice ne ''
110
                $invoice_unitprice && $invoice_unitprice ne ''
111
                ? (
111
                ? (
112
                    invoice_unitprice => $invoice_unitprice,
112
                    invoice_unitprice => $invoice_unitprice,
113
                    invoice_currency  => $invoice_currency,
113
                    invoice_currency  => $invoice_currency,
114
                  )
114
                  )
115
                : ()
115
                : (
116
                    invoice_unitprice => undef,
117
                    invoice_currency  => undef,
118
                )
116
            ),
119
            ),
117
        }
120
        }
118
    );
121
    );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-2 / +6 lines)
Lines 611-622 Link Here
611
                    $("#unitprice").prop("readonly", "true");
611
                    $("#unitprice").prop("readonly", "true");
612
                } else {
612
                } else {
613
                    $("#select_currency").hide();
613
                    $("#select_currency").hide();
614
                    $("#invoice_unitprice").val(""); // Empty to not store the values
615
                    $("#invoice_currency").val("");
614
                    $("#unitprice").prop("readonly", "");
616
                    $("#unitprice").prop("readonly", "");
615
                }
617
                }
616
            }).change();
618
            });
617
619
618
            [% IF order.invoice_unitprice %]
620
            [% IF order.invoice_unitprice %]
619
                $("input[name='change_currency']").click().trigger('change');
621
                $("input[name='change_currency']").click();
622
            [% ELSE %]
623
                $("input[name='change_currency']").trigger('change');
620
            [% END %]
624
            [% END %]
621
625
622
            function update_unitprice() {
626
            function update_unitprice() {
(-)a/t/db_dependent/Acquisition.t (-3 / +173 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use POSIX qw(strftime);
20
use POSIX qw(strftime);
21
21
22
use Test::More tests => 71;
22
use Test::More tests => 72;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::DateUtils qw(dt_from_string output_pref);
25
use Koha::DateUtils qw(dt_from_string output_pref);
Lines 783-792 subtest 'ModReceiveOrder and subscription' => sub { Link Here
783
    is( $received_order->order_internalnote,
783
    is( $received_order->order_internalnote,
784
        $second_note, "No price set if none passed in" );
784
        $second_note, "No price set if none passed in" );
785
785
786
    $order->get_from_storage;
787
    is( $order->get_from_storage->order_internalnote, $first_note );
786
    is( $order->get_from_storage->order_internalnote, $first_note );
788
};
787
};
789
788
789
subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub {
790
    plan tests => 2;
791
792
    my $builder = t::lib::TestBuilder->new;
793
    subtest 'partial order' => sub {
794
        plan tests => 2;
795
796
        subtest 'no invoice_unitprice' => sub {
797
            plan tests => 4;
798
            my $order = $builder->build_object(
799
                {
800
                    class => 'Koha::Acquisition::Orders',
801
                    value => {
802
                        quantity               => 5,
803
                        quantityreceived       => 0,
804
                        ecost_tax_excluded     => 42,
805
                        unitprice_tax_excluded => 42,
806
                    }
807
                }
808
            );
809
            my $order_info = {
810
                %{ $order->unblessed },
811
                invoice_unitprice => undef,
812
                invoice_currency  => undef,
813
            };
814
            my ( undef, $received_ordernumber ) = ModReceiveOrder(
815
                {
816
                    biblionumber     => $order->biblionumber,
817
                    order            => $order_info,
818
                    quantityreceived => 1,                   # We receive only 1
819
                    budget_id        => $order->budget_id,
820
                }
821
            );
822
            my $received_order =
823
              Koha::Acquisition::Orders->find($received_ordernumber);
824
            is( $received_order->invoice_unitprice,
825
                undef, 'no price should be stored if none passed' );
826
            is( $received_order->invoice_currency,
827
                undef, 'no currency should be stored if none passed' );
828
            $order = $order->get_from_storage;
829
            is( $order->invoice_unitprice, undef,
830
                'no price should be stored if none passed' );
831
            is( $order->invoice_currency, undef,
832
                'no currency should be stored if none passed' );
833
        };
834
        subtest 'with invoice_unitprice' => sub {
835
            plan tests => 4;
836
            my $order = $builder->build_object(
837
                {
838
                    class => 'Koha::Acquisition::Orders',
839
                    value => {
840
                        quantity               => 5,
841
                        quantityreceived       => 0,
842
                        ecost_tax_excluded     => 42,
843
                        unitprice_tax_excluded => 42,
844
                    }
845
                }
846
            );
847
            my $order_info = {
848
                %{ $order->unblessed },
849
                invoice_unitprice => 37,
850
                invoice_currency  => 'GBP',
851
            };
852
            my ( undef, $received_ordernumber ) = ModReceiveOrder(
853
                {
854
                    biblionumber     => $order->biblionumber,
855
                    order            => $order_info,
856
                    quantityreceived => 1,
857
                    budget_id        => $order->budget_id,
858
                }
859
            );
860
            my $received_order =
861
              Koha::Acquisition::Orders->find($received_ordernumber);
862
            is( $received_order->invoice_unitprice + 0,
863
                37, 'price should be stored in new order' );
864
            is( $received_order->invoice_currency,
865
                'GBP', 'currency should be stored in new order' );
866
            $order = $order->get_from_storage;
867
            is( $order->invoice_unitprice + 0,
868
                37, 'price should be stored in existing order' );
869
            is( $order->invoice_currency, 'GBP',
870
                'currency should be stored in existing order' );
871
872
        };
873
    };
874
875
    subtest 'full received order' => sub {
876
        plan tests => 2;
877
878
        subtest 'no invoice_unitprice' => sub {
879
            plan tests => 4;
880
            my $builder = t::lib::TestBuilder->new;
881
            my $order   = $builder->build_object(
882
                {
883
                    class => 'Koha::Acquisition::Orders',
884
                    value => {
885
                        quantity               => 5,
886
                        quantityreceived       => 0,
887
                        ecost_tax_excluded     => 42,
888
                        unitprice_tax_excluded => 42,
889
                    }
890
                }
891
            );
892
            my $order_info = {
893
                %{ $order->unblessed },
894
                invoice_unitprice => undef,
895
                invoice_currency  => undef,
896
            };
897
            my ( undef, $received_ordernumber ) = ModReceiveOrder(
898
                {
899
                    biblionumber => $order->biblionumber,
900
                    order        => $order_info,
901
                    quantityreceived => 5,                # We receive them all!
902
                    budget_id        => $order->budget_id,
903
                }
904
            );
905
            my $received_order =
906
              Koha::Acquisition::Orders->find($received_ordernumber);
907
            is( $received_order->invoice_unitprice,
908
                undef, 'no price should be stored if none passed' );
909
            is( $received_order->invoice_currency,
910
                undef, 'no currency should be stored if none passed' );
911
            $order = $order->get_from_storage;
912
            is( $order->invoice_unitprice, undef,
913
                'no price should be stored if none passed' );
914
            is( $order->invoice_currency, undef,
915
                'no currency should be stored if none passed' );
916
        };
917
918
        subtest 'with invoice_unitprice' => sub {
919
            plan tests => 4;
920
            my $order = $builder->build_object(
921
                {
922
                    class => 'Koha::Acquisition::Orders',
923
                    value => {
924
                        quantity               => 5,
925
                        quantityreceived       => 0,
926
                        ecost_tax_excluded     => 42,
927
                        unitprice_tax_excluded => 42,
928
                    }
929
                }
930
            );
931
            my $order_info = {
932
                %{ $order->unblessed },
933
                invoice_unitprice => 37,
934
                invoice_currency  => 'GBP',
935
            };
936
            my ( undef, $received_ordernumber ) = ModReceiveOrder(
937
                {
938
                    biblionumber     => $order->biblionumber,
939
                    order            => $order_info,
940
                    quantityreceived => 1,
941
                    budget_id        => $order->budget_id,
942
                }
943
            );
944
            my $received_order =
945
              Koha::Acquisition::Orders->find($received_ordernumber);
946
            is( $received_order->invoice_unitprice + 0,
947
                37, 'price should be stored in new order' );
948
            is( $received_order->invoice_currency,
949
                'GBP', 'currency should be stored in new order' );
950
            $order = $order->get_from_storage;
951
            is( $order->invoice_unitprice + 0,
952
                37, 'price should be stored in existing order' );
953
            is( $order->invoice_currency, 'GBP',
954
                'currency should be stored in existing order' );
955
956
        };
957
    };
958
959
};
960
790
subtest 'GetHistory with additional fields' => sub {
961
subtest 'GetHistory with additional fields' => sub {
791
    plan tests => 3;
962
    plan tests => 3;
792
    my $builder = t::lib::TestBuilder->new;
963
    my $builder = t::lib::TestBuilder->new;
793
- 

Return to bug 25655