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

(-)a/t/db_dependent/Koha/Account.t (-9 / +10 lines)
Lines 1084-1125 subtest 'Koha::Account::pay() generates credit number (Koha::Account::Line->stor Link Here
1084
    for my $i (1..11) {
1084
    for my $i (1..11) {
1085
        $accountlines_id = $account->pay({ amount => '1.00', library_id => $library->id })->{payment_id};
1085
        $accountlines_id = $account->pay({ amount => '1.00', library_id => $library->id })->{payment_id};
1086
        $accountline = Koha::Account::Lines->find($accountlines_id);
1086
        $accountline = Koha::Account::Lines->find($accountlines_id);
1087
        is($accountline->credit_number, $i);
1087
        is($accountline->credit_number, $i, "Incremental format credit number added for payments: $i");
1088
    }
1088
    }
1089
    $accountlines_id = $account->pay({ type => 'WRITEOFF', amount => '1.00', library_id => $library->id })->{payment_id};
1089
    $accountlines_id = $account->pay({ type => 'WRITEOFF', amount => '1.00', library_id => $library->id })->{payment_id};
1090
    $accountline = Koha::Account::Lines->find($accountlines_id);
1090
    $accountline = Koha::Account::Lines->find($accountlines_id);
1091
    is($accountline->credit_number, undef);
1091
    is($accountline->credit_number, undef, "Incremental credit number not added for writeoff");
1092
1092
1093
    t::lib::Mocks::mock_preference('AutoCreditNumber', 'annual');
1093
    t::lib::Mocks::mock_preference('AutoCreditNumber', 'annual');
1094
    for my $i (1..11) {
1094
    for my $i (1..11) {
1095
        $accountlines_id = $account->pay({ amount => '1.00', library_id => $library->id })->{payment_id};
1095
        $accountlines_id = $account->pay({ amount => '1.00', library_id => $library->id })->{payment_id};
1096
        $accountline = Koha::Account::Lines->find($accountlines_id);
1096
        $accountline = Koha::Account::Lines->find($accountlines_id);
1097
        is($accountline->credit_number, sprintf('%s-%04d', $year, $i));
1097
        is($accountline->credit_number, sprintf('%s-%04d', $year, $i), "Annual format credit number added for payments: " . sprintf('%s-%04d', $year, $i));
1098
    }
1098
    }
1099
    $accountlines_id = $account->pay({ type => 'WRITEOFF', amount => '1.00', library_id => $library->id })->{payment_id};
1099
    $accountlines_id = $account->pay({ type => 'WRITEOFF', amount => '1.00', library_id => $library->id })->{payment_id};
1100
    $accountline = Koha::Account::Lines->find($accountlines_id);
1100
    $accountline = Koha::Account::Lines->find($accountlines_id);
1101
    is($accountline->credit_number, undef);
1101
    is($accountline->credit_number, undef, "Annual format credit number not aded for writeoff");
1102
1102
1103
    t::lib::Mocks::mock_preference('AutoCreditNumber', 'branchyyyymmincr');
1103
    t::lib::Mocks::mock_preference('AutoCreditNumber', 'branchyyyymmincr');
1104
    for my $i (1..11) {
1104
    for my $i (1..11) {
1105
        $accountlines_id = $account->pay({ amount => '1.00', library_id => $library->id })->{payment_id};
1105
        $accountlines_id = $account->pay({ amount => '1.00', library_id => $library->id })->{payment_id};
1106
        $accountline = Koha::Account::Lines->find($accountlines_id);
1106
        $accountline = Koha::Account::Lines->find($accountlines_id);
1107
        is($accountline->credit_number, sprintf('%s%d%02d%04d', $library->id, $year, $month, $i));
1107
        is($accountline->credit_number, sprintf('%s%d%02d%04d', $library->id, $year, $month, $i), "branchyyyymmincr format credit number added for payment: " . sprintf('%s%d%02d%04d', $library->id, $year, $month, $i));
1108
    }
1108
    }
1109
    $accountlines_id = $account->pay({ type => 'WRITEOFF', amount => '1.00', library_id => $library->id })->{payment_id};
1109
    $accountlines_id = $account->pay({ type => 'WRITEOFF', amount => '1.00', library_id => $library->id })->{payment_id};
1110
    $accountline = Koha::Account::Lines->find($accountlines_id);
1110
    $accountline = Koha::Account::Lines->find($accountlines_id);
1111
    is($accountline->credit_number, undef);
1111
    is($accountline->credit_number, undef, "branchyyyymmincr format credit number not added for writeoff");
1112
1112
1113
    throws_ok {
1113
    throws_ok {
1114
        Koha::Account::Line->new(
1114
        Koha::Account::Line->new(
1115
            {
1115
            {
1116
                interface        => 'test',
1117
                amount           => -1,
1116
                credit_type_code => $credit_type->code,
1118
                credit_type_code => $credit_type->code,
1117
                credit_number    => 42
1119
                credit_number    => 42
1118
            }
1120
            }
1119
        )->store;
1121
        )->store;
1120
    }
1122
    }
1121
    qr/AutoCreditNumber is enabled but credit_number is already defined!/,
1123
    'Koha::Exceptions::Account',
1122
      'Croaked on bad call to store';
1124
"Exception thrown when AutoCreditNumber is enabled but credit_number is already defined";
1123
1125
1124
    $schema->storage->txn_rollback;
1126
    $schema->storage->txn_rollback;
1125
};
1127
};
1126
- 

Return to bug 19036