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

(-)a/Koha/Item.pm (-8 / +21 lines)
Lines 997-1010 sub _set_found_trigger { Link Here
997
            if ( $patron ) {
997
            if ( $patron ) {
998
998
999
                my $account = $patron->account;
999
                my $account = $patron->account;
1000
                my $total_to_refund = 0;
1001
1000
1002
                # Use cases
1001
                # Credit outstanding amount
1003
                if ( $lost_charge->amount > $lost_charge->amountoutstanding ) {
1002
                my $credit_total = $lost_charge->amountoutstanding;
1004
1003
1004
                # Use cases
1005
                if (
1006
                    $lost_charge->amount > $lost_charge->amountoutstanding &&
1007
                    $lostreturn_policy ne "refund_unpaid"
1008
                ) {
1005
                    # some amount has been cancelled. collect the offsets that are not writeoffs
1009
                    # some amount has been cancelled. collect the offsets that are not writeoffs
1006
                    # this works because the only way to subtract from this kind of a debt is
1010
                    # this works because the only way to subtract from this kind of a debt is
1007
                    # using the UI buttons 'Pay' and 'Write off'
1011
                    # using the UI buttons 'Pay' and 'Write off'
1012
1013
                    # We don't credit any payments if return policy is
1014
                    # "refund_unpaid"
1015
                    #
1016
                    # In that case only unpaid/outstanding amount
1017
                    # will be credited wich settles the debt without
1018
                    # creating extra credits
1019
1008
                    my $credit_offsets = $lost_charge->debit_offsets(
1020
                    my $credit_offsets = $lost_charge->debit_offsets(
1009
                        {
1021
                        {
1010
                            'credit_id'               => { '!=' => undef },
1022
                            'credit_id'               => { '!=' => undef },
Lines 1013-1025 sub _set_found_trigger { Link Here
1013
                        { join => 'credit' }
1025
                        { join => 'credit' }
1014
                    );
1026
                    );
1015
1027
1016
                    $total_to_refund = ( $credit_offsets->count > 0 )
1028
                    my $total_to_refund = ( $credit_offsets->count > 0 )
1017
                      ? $credit_offsets->total * -1    # credits are negative on the DB
1029
                    ? $credit_offsets->total * -1    # credits are negative on the DB
1018
                      : 0;
1030
                    : 0;
1031
                    # Credit the outstanding amount, then add what has been
1032
                    # paid to create a net credit for this amount
1033
                    $credit_total += $total_to_refund;
1019
                }
1034
                }
1020
1035
1021
                my $credit_total = $lost_charge->amountoutstanding + $total_to_refund;
1022
1023
                my $credit;
1036
                my $credit;
1024
                if ( $credit_total > 0 ) {
1037
                if ( $credit_total > 0 ) {
1025
                    my $branchcode =
1038
                    my $branchcode =
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +24 lines)
Lines 810-835 Link Here
810
                          [% IF ( current_branch == '*' ) %]
810
                          [% IF ( current_branch == '*' ) %]
811
                            [% IF ( defaultRefundRule == 'refund' ) %]
811
                            [% IF ( defaultRefundRule == 'refund' ) %]
812
                            <option value="refund" selected="selected">Refund lost item charge</option>
812
                            <option value="refund" selected="selected">Refund lost item charge</option>
813
                            <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
814
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
815
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
816
                            <option value="0">Leave lost item charge</option>
817
                            [% ELSIF ( defaultRefundRule == 'refund_unpaid' ) %]
818
                            <option value="refund">Refund lost item charge</option>
819
                            <option value="refund_unpaid" selected="selected">Refund lost item charge (only if unpaid)</option>
813
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
820
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
814
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
821
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
815
                            <option value="0">Leave lost item charge</option>
822
                            <option value="0">Leave lost item charge</option>
816
                            [% ELSIF ( defaultRefundRule == 'charge' ) %]
823
                            [% ELSIF ( defaultRefundRule == 'charge' ) %]
817
                            <option value="refund">Refund lost item charge</option>
824
                            <option value="refund">Refund lost item charge</option>
825
                            <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
818
                            <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
826
                            <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
819
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
827
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
820
                            <option value="0">Leave lost item charge</option>
828
                            <option value="0">Leave lost item charge</option>
821
                            [% ELSIF ( defaultRefundRule == 'restore' ) %]
829
                            [% ELSIF ( defaultRefundRule == 'restore' ) %]
822
                            <option value="refund">Refund lost item charge</option>
830
                            <option value="refund">Refund lost item charge</option>
831
                            <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
823
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
832
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
824
                            <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
833
                            <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
825
                            <option value="0">Leave lost item charge</option>
834
                            <option value="0">Leave lost item charge</option>
826
                            [% ELSIF ( defaultRefundRule == 0 ) %]
835
                            [% ELSIF ( defaultRefundRule == 0 ) %]
827
                            <option value="refund">Refund lost item charge</option>
836
                            <option value="refund">Refund lost item charge</option>
837
                            <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
828
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
838
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
829
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
839
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
830
                            <option value="0" selected="selected">Leave lost item charge</option>
840
                            <option value="0" selected="selected">Leave lost item charge</option>
831
                            [% ELSE %]
841
                            [% ELSE %]
832
                            <option value="refund">Refund lost item charge</option>
842
                            <option value="refund">Refund lost item charge</option>
843
                            <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
833
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
844
                            <option value="charge">Refund lost item charge and charge new overdue fine</option>
834
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
845
                            <option value="restore">Refund lost item charge and restore overdue fine</option>
835
                            <option value="0">Leave lost item charge</option>
846
                            <option value="0">Leave lost item charge</option>
Lines 843-848 Link Here
843
                            [% END %]
854
                            [% END %]
844
                              [% IF defaultRefundRule == 'refund' %]
855
                              [% IF defaultRefundRule == 'refund' %]
845
                                Use default (Refund lost item charge)
856
                                Use default (Refund lost item charge)
857
                              [% ELSIF defaultRefundRule == 'refund_unpaid' %]
858
                                Use default (Refund lost item charge (only if unpaid))
846
                              [% ELSIF defaultRefundRule == 'charge' %]
859
                              [% ELSIF defaultRefundRule == 'charge' %]
847
                                Use default (Refund lost item charge and restore overdue fine)
860
                                Use default (Refund lost item charge and restore overdue fine)
848
                              [% ELSIF defaultRefundRule == 'restore' %]
861
                              [% ELSIF defaultRefundRule == 'restore' %]
Lines 853-879 Link Here
853
                                </option>
866
                                </option>
854
                            [% IF ( not refundLostItemFeeRule ) %]
867
                            [% IF ( not refundLostItemFeeRule ) %]
855
                                <option value="refund">Refund lost item charge</option>
868
                                <option value="refund">Refund lost item charge</option>
869
                                <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
856
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
870
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
857
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
871
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
858
                                <option value="0">Leave lost item charge</option>
872
                                <option value="0">Leave lost item charge</option>
859
                            [% ELSE %]
873
                            [% ELSE %]
860
                                [% IF ( refundLostItemFeeRule.rule_value == 'refund' ) %]
874
                                [% IF ( refundLostItemFeeRule.rule_value == 'refund' ) %]
861
                                <option value="refund" selected="selected">Refund lost item charge</option>
875
                                <option value="refund" selected="selected">Refund lost item charge</option>
876
                                <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
862
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
877
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
863
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
878
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
864
                                <option value="0">Leave lost item charge</option>
879
                                <option value="0">Leave lost item charge</option>
880
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 'refund_unpaid' ) %]
881
                                <option value="refund">Refund lost item charge</option>
882
                                <option value="refund_unpaid" selected="selected">Refund lost item charge (only if unpaid)</option>
883
                                <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
884
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
885
                                <option value="0">Leave lost item charge</option>
865
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 'charge' ) %]
886
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 'charge' ) %]
866
                                <option value="refund">Refund lost item charge</option>
887
                                <option value="refund">Refund lost item charge</option>
888
                                <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
867
                                <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
889
                                <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option>
868
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
890
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
869
                                <option value="0">Leave lost item charge</option>
891
                                <option value="0">Leave lost item charge</option>
870
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 'restore' ) %]
892
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 'restore' ) %]
871
                                <option value="refund">Refund lost item charge</option>
893
                                <option value="refund">Refund lost item charge</option>
894
                                <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
872
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
895
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
873
                                <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
896
                                <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option>
874
                                <option value="0">Leave lost item charge</option>
897
                                <option value="0">Leave lost item charge</option>
875
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 0 ) %]
898
                                [% ELSIF ( refundLostItemFeeRule.rule_value == 0 ) %]
876
                                <option value="refund">Refund lost item charge</option>
899
                                <option value="refund">Refund lost item charge</option>
900
                                <option value="refund_unpaid">Refund lost item charge (only if unpaid)</option>
877
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
901
                                <option value="charge">Refund lost item charge and charge new overdue fine</option>
878
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
902
                                <option value="restore">Refund lost item charge and restore overdue fine</option>
879
                                <option value="0" selected="selected">Leave lost item charge</option>
903
                                <option value="0" selected="selected">Leave lost item charge</option>
880
- 

Return to bug 20262