|
Lines 1264-1282
subtest 'Koha::Account::payout_amount() tests' => sub {
Link Here
|
| 1264 |
my $offsets = Koha::Account::Offsets->search( { debit_id => $payout->id } ); |
1264 |
my $offsets = Koha::Account::Offsets->search( { debit_id => $payout->id } ); |
| 1265 |
is( $offsets->count, 4, 'Four offsets generated' ); |
1265 |
is( $offsets->count, 4, 'Four offsets generated' ); |
| 1266 |
my $offset = $offsets->next; |
1266 |
my $offset = $offsets->next; |
| 1267 |
is( $offset->type, 'PAYOUT', 'PAYOUT offset added for payout line' ); |
1267 |
is( $offset->type, 'CREATE', 'CREATE offset added for payout line' ); |
| 1268 |
is( $offset->amount * 1, 10, 'Correct offset amount recorded' ); |
1268 |
is( $offset->amount * 1, 10, 'Correct offset amount recorded' ); |
| 1269 |
$offset = $offsets->next; |
1269 |
$offset = $offsets->next; |
| 1270 |
is( $offset->credit_id, $credit_1->id, "Offset added against credit_1"); |
1270 |
is( $offset->credit_id, $credit_1->id, "Offset added against credit_1"); |
| 1271 |
is( $offset->type, 'PAYOUT', "PAYOUT used for offset_type" ); |
1271 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1272 |
is( $offset->amount * 1, -2, 'Correct amount offset against credit_1' ); |
1272 |
is( $offset->amount * 1, -2, 'Correct amount offset against credit_1' ); |
| 1273 |
$offset = $offsets->next; |
1273 |
$offset = $offsets->next; |
| 1274 |
is( $offset->credit_id, $credit_2->id, "Offset added against credit_2"); |
1274 |
is( $offset->credit_id, $credit_2->id, "Offset added against credit_2"); |
| 1275 |
is( $offset->type, 'PAYOUT', "PAYOUT used for offset_type" ); |
1275 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1276 |
is( $offset->amount * 1, -3, 'Correct amount offset against credit_2' ); |
1276 |
is( $offset->amount * 1, -3, 'Correct amount offset against credit_2' ); |
| 1277 |
$offset = $offsets->next; |
1277 |
$offset = $offsets->next; |
| 1278 |
is( $offset->credit_id, $credit_3->id, "Offset added against credit_3"); |
1278 |
is( $offset->credit_id, $credit_3->id, "Offset added against credit_3"); |
| 1279 |
is( $offset->type, 'PAYOUT', "PAYOUT used for offset_type" ); |
1279 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1280 |
is( $offset->amount * 1, -5, 'Correct amount offset against credit_3' ); |
1280 |
is( $offset->amount * 1, -5, 'Correct amount offset against credit_3' ); |
| 1281 |
|
1281 |
|
| 1282 |
my $credit_5 = $account->add_credit( { amount => 5, interface => 'commandline' } ); |
1282 |
my $credit_5 = $account->add_credit( { amount => 5, interface => 'commandline' } ); |
|
Lines 1297-1307
subtest 'Koha::Account::payout_amount() tests' => sub {
Link Here
|
| 1297 |
$offsets = Koha::Account::Offsets->search( { debit_id => $payout->id } ); |
1297 |
$offsets = Koha::Account::Offsets->search( { debit_id => $payout->id } ); |
| 1298 |
is( $offsets->count, 2, 'Two offsets generated' ); |
1298 |
is( $offsets->count, 2, 'Two offsets generated' ); |
| 1299 |
$offset = $offsets->next; |
1299 |
$offset = $offsets->next; |
| 1300 |
is( $offset->type, 'PAYOUT', 'PAYOUT offset added for payout line' ); |
1300 |
is( $offset->type, 'CREATE', 'CREATE offset added for payout line' ); |
| 1301 |
is( $offset->amount * 1, 2.50, 'Correct offset amount recorded' ); |
1301 |
is( $offset->amount * 1, 2.50, 'Correct offset amount recorded' ); |
| 1302 |
$offset = $offsets->next; |
1302 |
$offset = $offsets->next; |
| 1303 |
is( $offset->credit_id, $credit_5->id, "Offset added against credit_5"); |
1303 |
is( $offset->credit_id, $credit_5->id, "Offset added against credit_5"); |
| 1304 |
is( $offset->type, 'PAYOUT', "PAYOUT used for offset_type" ); |
1304 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1305 |
is( $offset->amount * 1, -2.50, 'Correct amount offset against credit_5' ); |
1305 |
is( $offset->amount * 1, -2.50, 'Correct amount offset against credit_5' ); |
| 1306 |
|
1306 |
|
| 1307 |
$schema->storage->txn_rollback; |
1307 |
$schema->storage->txn_rollback; |
|
Lines 1391-1409
subtest 'Koha::Account::payin_amount() tests' => sub {
Link Here
|
| 1391 |
my $offsets = Koha::Account::Offsets->search( { credit_id => $payin->id } ); |
1391 |
my $offsets = Koha::Account::Offsets->search( { credit_id => $payin->id } ); |
| 1392 |
is( $offsets->count, 4, 'Four offsets generated' ); |
1392 |
is( $offsets->count, 4, 'Four offsets generated' ); |
| 1393 |
my $offset = $offsets->next; |
1393 |
my $offset = $offsets->next; |
| 1394 |
is( $offset->type, 'Payment', 'Payment offset added for payin line' ); |
1394 |
is( $offset->type, 'CREATE', 'CREATE offset added for payin line' ); |
| 1395 |
is( $offset->amount * 1, -10, 'Correct offset amount recorded' ); |
1395 |
is( $offset->amount * 1, -10, 'Correct offset amount recorded' ); |
| 1396 |
$offset = $offsets->next; |
1396 |
$offset = $offsets->next; |
| 1397 |
is( $offset->debit_id, $debit_1->id, "Offset added against debit_1"); |
1397 |
is( $offset->debit_id, $debit_1->id, "Offset added against debit_1"); |
| 1398 |
is( $offset->type, 'Payment', "Payment used for offset_type" ); |
1398 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1399 |
is( $offset->amount * 1, -2, 'Correct amount offset against debit_1' ); |
1399 |
is( $offset->amount * 1, -2, 'Correct amount offset against debit_1' ); |
| 1400 |
$offset = $offsets->next; |
1400 |
$offset = $offsets->next; |
| 1401 |
is( $offset->debit_id, $debit_2->id, "Offset added against debit_2"); |
1401 |
is( $offset->debit_id, $debit_2->id, "Offset added against debit_2"); |
| 1402 |
is( $offset->type, 'Payment', "Payment used for offset_type" ); |
1402 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1403 |
is( $offset->amount * 1, -3, 'Correct amount offset against debit_2' ); |
1403 |
is( $offset->amount * 1, -3, 'Correct amount offset against debit_2' ); |
| 1404 |
$offset = $offsets->next; |
1404 |
$offset = $offsets->next; |
| 1405 |
is( $offset->debit_id, $debit_3->id, "Offset added against debit_3"); |
1405 |
is( $offset->debit_id, $debit_3->id, "Offset added against debit_3"); |
| 1406 |
is( $offset->type, 'Payment', "Payment used for offset_type" ); |
1406 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1407 |
is( $offset->amount * 1, -5, 'Correct amount offset against debit_3' ); |
1407 |
is( $offset->amount * 1, -5, 'Correct amount offset against debit_3' ); |
| 1408 |
|
1408 |
|
| 1409 |
my $debit_5 = $account->add_debit( { amount => 5, interface => 'commandline', type => 'OVERDUE' } ); |
1409 |
my $debit_5 = $account->add_debit( { amount => 5, interface => 'commandline', type => 'OVERDUE' } ); |
|
Lines 1424-1434
subtest 'Koha::Account::payin_amount() tests' => sub {
Link Here
|
| 1424 |
$offsets = Koha::Account::Offsets->search( { credit_id => $payin->id } ); |
1424 |
$offsets = Koha::Account::Offsets->search( { credit_id => $payin->id } ); |
| 1425 |
is( $offsets->count, 2, 'Two offsets generated' ); |
1425 |
is( $offsets->count, 2, 'Two offsets generated' ); |
| 1426 |
$offset = $offsets->next; |
1426 |
$offset = $offsets->next; |
| 1427 |
is( $offset->type, 'Payment', 'Payment offset added for payin line' ); |
1427 |
is( $offset->type, 'CREATE', 'CREATE offset added for payin line' ); |
| 1428 |
is( $offset->amount * 1, -2.50, 'Correct offset amount recorded' ); |
1428 |
is( $offset->amount * 1, -2.50, 'Correct offset amount recorded' ); |
| 1429 |
$offset = $offsets->next; |
1429 |
$offset = $offsets->next; |
| 1430 |
is( $offset->debit_id, $debit_5->id, "Offset added against debit_5"); |
1430 |
is( $offset->debit_id, $debit_5->id, "Offset added against debit_5"); |
| 1431 |
is( $offset->type, 'Payment', "Payment used for offset_type" ); |
1431 |
is( $offset->type, 'APPLY', "APPLY used for offset_type" ); |
| 1432 |
is( $offset->amount * 1, -2.50, 'Correct amount offset against debit_5' ); |
1432 |
is( $offset->amount * 1, -2.50, 'Correct amount offset against debit_5' ); |
| 1433 |
|
1433 |
|
| 1434 |
$schema->storage->txn_rollback; |
1434 |
$schema->storage->txn_rollback; |