From cde1573c3273d4b180a319387700596f7c526407 Mon Sep 17 00:00:00 2001 From: Remington Steed Date: Tue, 21 Jul 2015 13:21:15 -0400 Subject: [PATCH] LP 1198465: More tests for conditional negative balances This commit adds the remaining test cases documented by Kathy Lussier on this wiki page: http://evergreen-ils.org/dokuwiki/doku.php?id=qa:billing_test_cases Test cases included in this commit are: 6. Restores Overdue Fines Appropriately, No Previous "Voids", Patron Will Not Owe On Lost Item Return 7. Restores Overdue Fines Appropriately, No Previous "Voids", Patron Will Still Owe On Lost Item Return 9. Restore Overdue Fines Appropriately, Previous Voids, Negative Balance Allowed 13. Prohibit negative balances on lost materials bills ONLY 14. Prohibit negative balances on overdue bills ONLY Note that test case 5 is omitted because it is a duplicate of case 2, and case 11 is included but commented out because it is unclear how best to handle the situation. Signed-off-by: Remington Steed Signed-off-by: Dan Wells Signed-off-by: Kathy Lussier Signed-off-by: Ben Shum --- .../live_t/09-lp1198465_neg_balances.t | 1072 ++++++++++++++--- .../lp1198465_run_this_before_livetests.sql | 195 ++- 2 files changed, 1017 insertions(+), 250 deletions(-) diff --git a/Open-ILS/src/perlmods/live_t/09-lp1198465_neg_balances.t b/Open-ILS/src/perlmods/live_t/09-lp1198465_neg_balances.t index 01c4fedccd..3ee057624a 100644 --- a/Open-ILS/src/perlmods/live_t/09-lp1198465_neg_balances.t +++ b/Open-ILS/src/perlmods/live_t/09-lp1198465_neg_balances.t @@ -1,6 +1,6 @@ #!perl -use Test::More tests => 64; +use Test::More tests => 127; diag("Test features of Conditional Negative Balances code."); @@ -149,7 +149,6 @@ if ($user_obj = retrieve_patron($patron_id)) { $xact_id = 1; $item_id = 2; $item_barcode = 'CONC4000037'; -$org_id = 1; #CONS $summary = fetch_billable_xact_summary($xact_id); ok( $summary, 'CASE 1: Found the transaction summary'); @@ -236,7 +235,6 @@ is( $xact_id = 2; $item_id = 3; $item_barcode = 'CONC4000038'; -$org_id = 1; #CONS $summary = fetch_billable_xact_summary($xact_id); ok( $summary, 'CASE 2: Found the transaction summary'); @@ -288,18 +286,36 @@ is( ############################## -# 3. Basic No Negative Balance Test +# 13. RERUN of Case 1. No Prohibit Negative Balance Settings Are Enabled, Payment Made +# SETTINGS: Prohibit negative balances on bills for lost materials ############################## +# Setup next patron +$patron_id = 6; +$patron_usrname = '99999335859'; + +# Look up the patron +if ($user_obj = retrieve_patron($patron_id)) { + is( + ref $user_obj, + 'Fieldmapper::actor::user', + 'open-ils.storage.direct.actor.user.retrieve returned aou object' + ); + is( + $user_obj->usrname, + $patron_usrname, + 'Patron with id = ' . $patron_id . ' has username ' . $patron_usrname + ); +} + ### Setup use case variables -$xact_id = 3; -$item_id = 4; -$item_barcode = 'CONC4000039'; -$org_id = 1; #CONS +$xact_id = 13; +$item_id = 14; +$item_barcode = 'CONC4000049'; # Setup Org Unit Settings $settings = { - 'bill.prohibit_negative_balance_default' => 1 + 'bill.prohibit_negative_balance_on_lost' => 1 }; $apputils->simplereq( 'open-ils.actor', @@ -310,18 +326,46 @@ $apputils->simplereq( ); $summary = fetch_billable_xact_summary($xact_id); -ok( $summary, 'CASE 3: Found the transaction summary'); +ok( $summary, 'CASE 13a: Found the transaction summary'); is( $summary->balance_owed, '50.00', 'Starting balance owed is 50.00 for lost item' ); +### pay the whole bill +$payment_blob = { + userid => $patron_id, + note => '09-lp1198465_neg_balances.t', + payment_type => 'cash_payment', + patron_credit => '0.00', + payments => [ [ $xact_id, '50.00' ] ] +}; +$pay_resp = pay_bills($payment_blob); + +is( + scalar( @{ $pay_resp->{payments} } ), + 1, + 'Payment response included one payment id' +); + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.00', + 'Remaining balance of 0.00 after payment' +); + ### check-in the lost copy $item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); if (my $item_resp = $item_req->recv) { if (my $item = $item_resp->content) { + is( + ref $item, + 'Fieldmapper::asset::copy', + 'open-ils.storage.direct.asset.copy.retrieve returned acp object' + ); is( $item->status, 3, @@ -354,49 +398,39 @@ $summary = fetch_billable_xact_summary($xact_id); is( $summary->balance_owed, '0.00', - 'Patron has a balance of 0.00 (negative balance prohibited)' + 'Patron has a balance of 0.00 (negative balance prevented)' ); + ############################## -# 4. Prohibit Negative Balances with Partial Payment +# 13. RERUN of Case 12. Test negative balance settings on fines +# SETTINGS: Prohibit negative balances on bills for lost materials ############################## ### Setup use case variables -$xact_id = 4; -$item_id = 5; -$item_barcode = 'CONC4000040'; -$org_id = 1; #CONS +$xact_id = 14; +$item_id = 15; +$item_barcode = 'CONC4000050'; # Setup Org Unit Settings -# already set: 'bill.prohibit_negative_balance_default' => 1 +# ALREADY SET: +# 'bill.prohibit_negative_balance_on_lost' => 1 $summary = fetch_billable_xact_summary($xact_id); -ok( $summary, 'CASE 4: Found the transaction summary'); +ok( $summary, 'CASE 13b: Found the transaction summary'); is( $summary->balance_owed, - '50.00', - 'Starting balance owed is 50.00 for lost item' + '0.70', + 'Starting balance owed is 0.70 for overdue fines' ); -### confirm the copy is lost -$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); -if (my $item_resp = $item_req->recv) { - if (my $item = $item_resp->content) { - is( - $item->status, - 3, - 'Item with id = ' . $item_id . ' has status of LOST' - ); - } -} - ### partially pay the bill $payment_blob = { userid => $patron_id, note => '09-lp1198465_neg_balances.t', payment_type => 'cash_payment', patron_credit => '0.00', - payments => [ [ $xact_id, '10.00' ] ] + payments => [ [ $xact_id, '0.20' ] ] }; $pay_resp = pay_bills($payment_blob); @@ -409,13 +443,15 @@ is( $summary = fetch_billable_xact_summary($xact_id); is( $summary->balance_owed, - '40.00', - 'Remaining balance of 40.00 after payment' + '0.50', + 'Remaining balance of 0.50 after payment' ); -### check-in the lost copy +### Check in using Amnesty Mode $checkin_resp = $script->do_checkin_override({ - barcode => $item_barcode}); + barcode => $item_barcode, + void_overdues => 1 +}); is( $checkin_resp->{ilsevent}, 0, @@ -433,138 +469,52 @@ if (my $item_resp = $item_req->recv) { } ### verify ending state - $summary = fetch_billable_xact_summary($xact_id); is( $summary->balance_owed, - '0.00', - 'Patron has a balance of 0.00 (negative balance prohibited)' + '-0.20', + 'Patron has a negative balance of -0.20 (refund of overdue fine payment)' ); -############################### -## 11. Manually voiding lost book fee does not result in negative balances -############################### -# -#### Setup use case variables -#$xact_id = 5; -#$item_id = 6; -#$item_barcode = 'CONC4000040'; -#$org_id = 1; #CONS -# -## Setup Org Unit Settings -## already set: 'bill.prohibit_negative_balance_default' => 1 -# -#$summary = fetch_billable_xact_summary($xact_id); -#ok( $summary, 'CASE 11: Found the transaction summary'); -#is( -# $summary->balance_owed, -# '50.00', -# 'Starting balance owed is 50.00 for lost item' -#); -# -#### confirm the copy is lost -#$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); -#if (my $item_resp = $item_req->recv) { -# if (my $item = $item_resp->content) { -# is( -# $item->status, -# 3, -# 'Item with id = ' . $item_id . ' has status of LOST' -# ); -# } -#} -# -#### partially pay the bill -#$payment_blob = { -# userid => $patron_id, -# note => '09-lp1198465_neg_balances.t', -# payment_type => 'cash_payment', -# patron_credit => '0.00', -# payments => [ [ $xact_id, '10.00' ] ] -#}; -#$pay_resp = pay_bills($payment_blob); -# -#is( -# scalar( @{ $pay_resp->{payments} } ), -# 1, -# 'Payment response included one payment id' -#); -# -#$summary = fetch_billable_xact_summary($xact_id); -#is( -# $summary->balance_owed, -# '40.00', -# 'Remaining balance of 40.00 after payment' -#); -# -#### TODO: manually void "the rest" of the bill (i.e. prevent neg bal) -#### XXX: HARDCODING billing id for now; should look up the LOST bill for this xact? -#my @billing_ids = (6); -#my $void_resp = void_bills(\@billing_ids); -# -#is( -# $void_resp, -# '1', -# 'Voiding was successful' -#); -# -#### verify ending state -# -#$summary = fetch_billable_xact_summary($xact_id); -#is( -# $summary->balance_owed, -# '0.00', -# 'Patron has a balance of 0.00 (negative balance prohibited)' -#); - - ############################## -# 12. Test negative balance settings on fines +# 14. RERUN of Case 1. No Prohibit Negative Balance Settings Are Enabled, Payment Made +# SETTINGS: Prohibit negative balances on bills for overdue materials ############################## -# Setup next patron -$patron_id = 5; -$patron_usrname = '99999387993'; - -# Look up the patron -if ($user_obj = retrieve_patron($patron_id)) { - is( - ref $user_obj, - 'Fieldmapper::actor::user', - 'open-ils.storage.direct.actor.user.retrieve returned aou object' - ); - is( - $user_obj->usrname, - $patron_usrname, - 'Patron with id = ' . $patron_id . ' has username ' . $patron_usrname - ); -} - ### Setup use case variables -$xact_id = 7; -$item_id = 8; -$item_barcode = 'CONC4000043'; -$org_id = 1; #CONS +$xact_id = 15; +$item_id = 16; +$item_barcode = 'CONC4000051'; # Setup Org Unit Settings -# already set: 'bill.prohibit_negative_balance_default' => 1 +$settings = { + 'bill.prohibit_negative_balance_on_lost' => 0, #unset from previous test + 'bill.prohibit_negative_balance_on_overdues' => 1 +}; +$apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.org_unit.settings.update', + $script->authtoken, + $org_id, + $settings +); $summary = fetch_billable_xact_summary($xact_id); -ok( $summary, 'CASE 12: Found the transaction summary'); +ok( $summary, 'CASE 14a: Found the transaction summary'); is( $summary->balance_owed, - '0.70', - 'Starting balance owed is 0.70 for overdue fines' + '50.00', + 'Starting balance owed is 50.00 for lost item' ); -### partially pay the bill +### pay the whole bill $payment_blob = { userid => $patron_id, note => '09-lp1198465_neg_balances.t', payment_type => 'cash_payment', patron_credit => '0.00', - payments => [ [ $xact_id, '0.20' ] ] + payments => [ [ $xact_id, '50.00' ] ] }; $pay_resp = pay_bills($payment_blob); @@ -577,15 +527,30 @@ is( $summary = fetch_billable_xact_summary($xact_id); is( $summary->balance_owed, - '0.50', - 'Remaining balance of 0.50 after payment' + '0.00', + 'Remaining balance of 0.00 after payment' ); -### Check in using Amnesty Mode +### check-in the lost copy + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + is( + ref $item, + 'Fieldmapper::asset::copy', + 'open-ils.storage.direct.asset.copy.retrieve returned acp object' + ); + is( + $item->status, + 3, + 'Item with id = ' . $item_id . ' has status of LOST' + ); + } +} + $checkin_resp = $script->do_checkin_override({ - barcode => $item_barcode, - void_overdues => 1 -}); + barcode => $item_barcode}); is( $checkin_resp->{ilsevent}, 0, @@ -603,49 +568,509 @@ if (my $item_resp = $item_req->recv) { } ### verify ending state + $summary = fetch_billable_xact_summary($xact_id); is( $summary->balance_owed, - '0.00', - 'Patron has a balance of 0.00 (remaining fines forgiven)' + '-50.00', + 'Patron has a negative balance (credit) of 50.00 due to overpayment' ); ############################## -# 10. Interval Testing +# 14. RERUN of Case 12. Test negative balance settings on fines +# SETTINGS: Prohibit negative balances on bills for overdue materials ############################## -# Setup Org Unit Settings -# already set: 'bill.prohibit_negative_balance_default' => 1 +### Setup use case variables +$xact_id = 16; +$item_id = 17; +$item_barcode = 'CONC4000052'; # Setup Org Unit Settings -$org_id = 1; #CONS -$settings = { - 'bill.negative_balance_interval_default' => '1 hour' -}; - -$apputils->simplereq( - 'open-ils.actor', - 'open-ils.actor.org_unit.settings.update', - $script->authtoken, - $org_id, - $settings -); - -### Setup use case variables -$xact_id = 8; -$item_id = 9; -$item_barcode = 'CONC4000044'; +# ALREADY SET: +# 'bill.prohibit_negative_balance_on_overdues' => 1 $summary = fetch_billable_xact_summary($xact_id); -ok( $summary, 'CASE 10.1: Found the transaction summary'); +ok( $summary, 'CASE 14b: Found the transaction summary'); is( $summary->balance_owed, - '0.00', - 'Starting balance owed is 0.00 (LOST fee paid)' -); + '0.70', + 'Starting balance owed is 0.70 for overdue fines' +); + +### partially pay the bill +$payment_blob = { + userid => $patron_id, + note => '09-lp1198465_neg_balances.t', + payment_type => 'cash_payment', + patron_credit => '0.00', + payments => [ [ $xact_id, '0.20' ] ] +}; +$pay_resp = pay_bills($payment_blob); + +is( + scalar( @{ $pay_resp->{payments} } ), + 1, + 'Payment response included one payment id' +); + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.50', + 'Remaining balance of 0.50 after payment' +); + +### Check in using Amnesty Mode +$checkin_resp = $script->do_checkin_override({ + barcode => $item_barcode, + void_overdues => 1 +}); +is( + $checkin_resp->{ilsevent}, + 0, + 'Checkin returned a SUCCESS event' +); + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + ok( + $item->status == 7 || $item->status == 0, + 'Item with id = ' . $item_id . ' has status of Reshelving or Available after fresh Storage request' + ); + } +} + +### verify ending state +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.00', + 'Patron has a balance of 0.00 (negative balance prevented)' +); + + +############################## +# 3. Basic No Negative Balance Test +############################## + +# Re-setup first patron +$patron_id = 4; +$patron_usrname = '99999355250'; + +# Look up the patron +if ($user_obj = retrieve_patron($patron_id)) { + is( + ref $user_obj, + 'Fieldmapper::actor::user', + 'open-ils.storage.direct.actor.user.retrieve returned aou object' + ); + is( + $user_obj->usrname, + $patron_usrname, + 'Patron with id = ' . $patron_id . ' has username ' . $patron_usrname + ); +} + + +### Setup use case variables +$xact_id = 3; +$item_id = 4; +$item_barcode = 'CONC4000039'; + +# Setup Org Unit Settings +$settings = { + 'bill.prohibit_negative_balance_on_overdues' => 0, #unset from previous test + 'bill.prohibit_negative_balance_default' => 1 +}; +$apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.org_unit.settings.update', + $script->authtoken, + $org_id, + $settings +); + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 3: Found the transaction summary'); +is( + $summary->balance_owed, + '50.00', + 'Starting balance owed is 50.00 for lost item' +); + +### check-in the lost copy + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + is( + $item->status, + 3, + 'Item with id = ' . $item_id . ' has status of LOST' + ); + } +} + +$checkin_resp = $script->do_checkin_override({ + barcode => $item_barcode}); +is( + $checkin_resp->{ilsevent}, + 0, + 'Checkin returned a SUCCESS event' +); + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + ok( + $item->status == 7 || $item->status == 0, + 'Item with id = ' . $item_id . ' has status of Reshelving or Available after fresh Storage request' + ); + } +} + +### verify ending state + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.00', + 'Patron has a balance of 0.00 (negative balance prevented)' +); + +############################## +# 4. Prohibit Negative Balances with Partial Payment +############################## + +### Setup use case variables +$xact_id = 4; +$item_id = 5; +$item_barcode = 'CONC4000040'; + +# Setup Org Unit Settings +# ALREADY SET: +# 'bill.prohibit_negative_balance_default' => 1 + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 4: Found the transaction summary'); +is( + $summary->balance_owed, + '50.00', + 'Starting balance owed is 50.00 for lost item' +); + +### confirm the copy is lost +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + is( + $item->status, + 3, + 'Item with id = ' . $item_id . ' has status of LOST' + ); + } +} + +### partially pay the bill +$payment_blob = { + userid => $patron_id, + note => '09-lp1198465_neg_balances.t', + payment_type => 'cash_payment', + patron_credit => '0.00', + payments => [ [ $xact_id, '10.00' ] ] +}; +$pay_resp = pay_bills($payment_blob); + +is( + scalar( @{ $pay_resp->{payments} } ), + 1, + 'Payment response included one payment id' +); + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '40.00', + 'Remaining balance of 40.00 after payment' +); + +### check-in the lost copy +$checkin_resp = $script->do_checkin_override({ + barcode => $item_barcode}); +is( + $checkin_resp->{ilsevent}, + 0, + 'Checkin returned a SUCCESS event' +); + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + ok( + $item->status == 7 || $item->status == 0, + 'Item with id = ' . $item_id . ' has status of Reshelving or Available after fresh Storage request' + ); + } +} + +### verify ending state + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.00', + 'Patron has a balance of 0.00 (negative balance prevented)' +); + + +############################### +## 11. Manually voiding lost book fee does not result in negative balances +############################### +# +#### Setup use case variables +#$xact_id = 5; +#$item_id = 6; +#$item_barcode = 'CONC4000040'; +# +## Setup Org Unit Settings +# ALREADY SET: +# 'bill.prohibit_negative_balance_default' => 1 +# +#$summary = fetch_billable_xact_summary($xact_id); +#ok( $summary, 'CASE 11: Found the transaction summary'); +#is( +# $summary->balance_owed, +# '50.00', +# 'Starting balance owed is 50.00 for lost item' +#); +# +#### confirm the copy is lost +#$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +#if (my $item_resp = $item_req->recv) { +# if (my $item = $item_resp->content) { +# is( +# $item->status, +# 3, +# 'Item with id = ' . $item_id . ' has status of LOST' +# ); +# } +#} +# +#### partially pay the bill +#$payment_blob = { +# userid => $patron_id, +# note => '09-lp1198465_neg_balances.t', +# payment_type => 'cash_payment', +# patron_credit => '0.00', +# payments => [ [ $xact_id, '10.00' ] ] +#}; +#$pay_resp = pay_bills($payment_blob); +# +#is( +# scalar( @{ $pay_resp->{payments} } ), +# 1, +# 'Payment response included one payment id' +#); +# +#$summary = fetch_billable_xact_summary($xact_id); +#is( +# $summary->balance_owed, +# '40.00', +# 'Remaining balance of 40.00 after payment' +#); +# +#### TODO: manually void "the rest" of the bill (i.e. prevent neg bal) +#### XXX: HARDCODING billing id for now; should look up the LOST bill for this xact? +#my @billing_ids = (6); +#my $void_resp = void_bills(\@billing_ids); +# +#is( +# $void_resp, +# '1', +# 'Voiding was successful' +#); +# +#### verify ending state +# +#$summary = fetch_billable_xact_summary($xact_id); +#is( +# $summary->balance_owed, +# '0.00', +# 'Patron has a balance of 0.00 (negative balance prohibited)' +#); + + +############################## +# 12. Test negative balance settings on fines +############################## + +# Setup next patron +$patron_id = 5; +$patron_usrname = '99999387993'; + +# Look up the patron +if ($user_obj = retrieve_patron($patron_id)) { + is( + ref $user_obj, + 'Fieldmapper::actor::user', + 'open-ils.storage.direct.actor.user.retrieve returned aou object' + ); + is( + $user_obj->usrname, + $patron_usrname, + 'Patron with id = ' . $patron_id . ' has username ' . $patron_usrname + ); +} + +### Setup use case variables +$xact_id = 7; +$item_id = 8; +$item_barcode = 'CONC4000043'; + +# Setup Org Unit Settings +# ALREADY SET: +# 'bill.prohibit_negative_balance_default' => 1 + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 12: Found the transaction summary'); +is( + $summary->balance_owed, + '0.70', + 'Starting balance owed is 0.70 for overdue fines' +); + +### partially pay the bill +$payment_blob = { + userid => $patron_id, + note => '09-lp1198465_neg_balances.t', + payment_type => 'cash_payment', + patron_credit => '0.00', + payments => [ [ $xact_id, '0.20' ] ] +}; +$pay_resp = pay_bills($payment_blob); + +is( + scalar( @{ $pay_resp->{payments} } ), + 1, + 'Payment response included one payment id' +); + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.50', + 'Remaining balance of 0.50 after payment' +); + +### Check in using Amnesty Mode +$checkin_resp = $script->do_checkin_override({ + barcode => $item_barcode, + void_overdues => 1 +}); +is( + $checkin_resp->{ilsevent}, + 0, + 'Checkin returned a SUCCESS event' +); + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + ok( + $item->status == 7 || $item->status == 0, + 'Item with id = ' . $item_id . ' has status of Reshelving or Available after fresh Storage request' + ); + } +} + +### verify ending state +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.00', + 'Patron has a balance of 0.00 (remaining fines forgiven)' +); + + +############################## +# 10. Interval Testing +############################## + +# Setup Org Unit Settings +# ALREADY SET: +# 'bill.prohibit_negative_balance_default' => 1 + +# Setup Org Unit Settings +$settings = { + 'bill.negative_balance_interval_default' => '1 hour' +}; + +$apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.org_unit.settings.update', + $script->authtoken, + $org_id, + $settings +); + +### Setup use case variables +$xact_id = 8; +$item_id = 9; +$item_barcode = 'CONC4000044'; + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 10.1: Found the transaction summary'); +is( + $summary->balance_owed, + '0.00', + 'Starting balance owed is 0.00 (LOST fee paid)' +); + +### Check in first item (right after its payment) +$checkin_resp = $script->do_checkin_override({ + barcode => $item_barcode, +}); +is( + $checkin_resp->{ilsevent}, + 0, + 'Checkin returned a SUCCESS event' +); + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + ok( + $item->status == 7 || $item->status == 0, + 'Item with id = ' . $item_id . ' has status of Reshelving or Available after fresh Storage request' + ); + } +} + +### verify ending state for 10.1 +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '-50.00', + 'Patron has a balance of -50.00 (lost item returned during interval)' +); -### Check in first item (right after its payment) +### Setup use case variables +$xact_id = 9; +$item_id = 10; +$item_barcode = 'CONC4000045'; + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 10.2: Found the transaction summary'); +is( + $summary->balance_owed, + '0.00', + 'Starting balance owed is 0.00 (LOST fee paid)' +); + +### Check in second item (2 hours after its payment) $checkin_resp = $script->do_checkin_override({ barcode => $item_barcode, }); @@ -665,31 +1090,286 @@ if (my $item_resp = $item_req->recv) { } } -### verify ending state for 10.1 +### verify ending state $summary = fetch_billable_xact_summary($xact_id); is( $summary->balance_owed, - '-50.00', - 'Patron has a balance of -50.00 (lost item returned during interval)' + '0.00', + 'Patron has a balance of 0.00 (lost item returned after interval)' ); + +############################# +# 6. Restores Overdue Fines Appropriately, No Previous "Voids", Patron Will Not Owe On Lost Item Return +############################# + ### Setup use case variables -$xact_id = 9; -$item_id = 10; -$item_barcode = 'CONC4000045'; +$xact_id = 10; +$item_id = 11; +$item_barcode = 'CONC4000046'; + +# Setup Org Unit Settings +$settings = { + 'bill.negative_balance_interval_default' => 0, #unset previous setting + 'circ.void_overdue_on_lost' => 1, + 'circ.restore_overdue_on_lost_return' => 1, + 'circ.lost.generate_overdue_on_checkin' => 1 +}; + +$apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.org_unit.settings.update', + $script->authtoken, + $org_id, + $settings +); + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 6: Found the transaction summary'); +is( + $summary->balance_owed, + '40.00', + 'Starting balance owed is 40.00 for partially paid lost item' +); + +### check-in the lost copy + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + is( + ref $item, + 'Fieldmapper::asset::copy', + 'open-ils.storage.direct.asset.copy.retrieve returned acp object' + ); + is( + $item->status, + 3, + 'Item with id = ' . $item_id . ' has status of LOST' + ); + } +} + +$checkin_resp = $script->do_checkin_override({ + barcode => $item_barcode}); +is( + $checkin_resp->{ilsevent}, + 0, + 'Checkin returned a SUCCESS event' +); + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + ok( + $item->status == 7 || $item->status == 0, + 'Item with id = ' . $item_id . ' has status of Reshelving or Available after fresh Storage request' + ); + } +} + +### verify ending state $summary = fetch_billable_xact_summary($xact_id); -ok( $summary, 'CASE 10.2: Found the transaction summary'); is( $summary->balance_owed, '0.00', - 'Starting balance owed is 0.00 (LOST fee paid)' + 'Patron has a balance of 0.00 (negative balance prevented)' ); -### Check in second item (2 hours after its payment) + +############################# +# 7. Restores Overdue Fines Appropriately, No Previous "Voids", Patron Will Still Owe On Lost Item Return +############################# + +### Setup use case variables +$xact_id = 11; +$item_id = 12; +$item_barcode = 'CONC4000047'; + +# Setup Org Unit Settings +# ALREADY SET: +# 'bill.prohibit_negative_balance_default' => 1 +# 'circ.void_overdue_on_lost' => 1, +# 'circ.restore_overdue_on_lost_return' => 1, +# 'circ.lost.generate_overdue_on_checkin' => 1 + +$apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.org_unit.settings.update', + $script->authtoken, + $org_id, + $settings +); + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 7: Found the transaction summary'); +is( + $summary->balance_owed, + '0.70', + 'Starting balance owed is 0.70 for overdues' +); + +### mark item as LOST +$apputils->simplereq( + 'open-ils.circ', + 'open-ils.circ.circulation.set_lost', + $script->authtoken, + {barcode => $item_barcode} +); + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'Found the transaction summary'); +is( + $summary->balance_owed, + '50.00', + 'New balance owed is 50.00 for LOST fee' +); + +### partially pay the bill +$payment_blob = { + userid => $patron_id, + note => '09-lp1198465_neg_balances.t', + payment_type => 'cash_payment', + patron_credit => '0.00', + payments => [ [ $xact_id, '0.10' ] ] +}; +$pay_resp = pay_bills($payment_blob); + +is( + scalar( @{ $pay_resp->{payments} } ), + 1, + 'Payment response included one payment id' +); + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '49.90', + 'Remaining balance of 49.90 after payment' +); + +### check-in the lost copy + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + is( + ref $item, + 'Fieldmapper::asset::copy', + 'open-ils.storage.direct.asset.copy.retrieve returned acp object' + ); + is( + $item->status, + 3, + 'Item with id = ' . $item_id . ' has status of LOST' + ); + } +} + $checkin_resp = $script->do_checkin_override({ - barcode => $item_barcode, -}); + barcode => $item_barcode}); +is( + $checkin_resp->{ilsevent}, + 0, + 'Checkin returned a SUCCESS event' +); + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + ok( + $item->status == 7 || $item->status == 0, + 'Item with id = ' . $item_id . ' has status of Reshelving or Available after fresh Storage request' + ); + } +} + +### verify ending state + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '0.60', + 'Patron has a balance of 0.60 due to reinstated overdue fines' +); + + +############################# +# 9. Restore Overdue Fines Appropriately, Previous Voids, Negative Balance Allowed +############################# + +### Setup use case variables +$xact_id = 12; +$item_id = 13; +$item_barcode = 'CONC4000048'; + +# Setup Org Unit Settings +# ALREADY SET: +# 'bill.prohibit_negative_balance_default' => 1 +# 'circ.void_overdue_on_lost' => 1, +# 'circ.restore_overdue_on_lost_return' => 1, +# 'circ.lost.generate_overdue_on_checkin' => 1 + +$apputils->simplereq( + 'open-ils.actor', + 'open-ils.actor.org_unit.settings.update', + $script->authtoken, + $org_id, + $settings +); + +$summary = fetch_billable_xact_summary($xact_id); +ok( $summary, 'CASE 9: Found the transaction summary'); +is( + $summary->balance_owed, + '50.00', + 'Starting balance owed is 50.00 for lost item' +); + +### partially pay the bill +$payment_blob = { + userid => $patron_id, + note => '09-lp1198465_neg_balances.t', + payment_type => 'cash_payment', + patron_credit => '0.00', + payments => [ [ $xact_id, '10.00' ] ] +}; +$pay_resp = pay_bills($payment_blob); + +is( + scalar( @{ $pay_resp->{payments} } ), + 1, + 'Payment response included one payment id' +); + +$summary = fetch_billable_xact_summary($xact_id); +is( + $summary->balance_owed, + '40.00', + 'Remaining balance of 40.00 after payment' +); + +### check-in the lost copy + +$item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', $item_id); +if (my $item_resp = $item_req->recv) { + if (my $item = $item_resp->content) { + is( + ref $item, + 'Fieldmapper::asset::copy', + 'open-ils.storage.direct.asset.copy.retrieve returned acp object' + ); + is( + $item->status, + 3, + 'Item with id = ' . $item_id . ' has status of LOST' + ); + } +} + +$checkin_resp = $script->do_checkin_override({ + barcode => $item_barcode}); is( $checkin_resp->{ilsevent}, 0, @@ -707,11 +1387,12 @@ if (my $item_resp = $item_req->recv) { } ### verify ending state + $summary = fetch_billable_xact_summary($xact_id); is( $summary->balance_owed, '0.00', - 'Patron has a balance of 0.00 (lost item returned after interval)' + 'Patron has a balance of 0.00 (negative balance prevented)' ); @@ -743,13 +1424,14 @@ if ($user_obj = retrieve_patron($patron_id)) { $xact_id = 6; $item_id = 7; $item_barcode = 'CONC4000042'; -$org_id = 1; #CONS # Setup Org Unit Settings +# ALREADY SET: +# 'circ.void_overdue_on_lost' => 1, +# 'circ.restore_overdue_on_lost_return' => 1, +# 'circ.lost.generate_overdue_on_checkin' => 1 $settings = { - 'bill.prohibit_negative_balance_default' => 0, - 'circ.restore_overdue_on_lost_return' => 1, - 'circ.lost.generate_overdue_on_checkin' => 1 + 'bill.prohibit_negative_balance_default' => 0 }; $apputils->simplereq( diff --git a/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql b/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql index c578cad64d..194963b922 100644 --- a/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql +++ b/Open-ILS/src/sql/Pg/live_t/lp1198465_run_this_before_livetests.sql @@ -9,11 +9,9 @@ BEGIN; -- NOTE: Org unit settings will be handled in the perl code --- user id: 4, name: Gregory Jones - -- clear bills and payments for our test circs -DELETE FROM money.billing WHERE xact <= 9; -DELETE FROM money.payment WHERE xact <= 9; +DELETE FROM money.billing WHERE xact <= 16; +DELETE FROM money.payment WHERE xact <= 16; -- clear any non-stock settings -- XXX This will need adjusting if new stock settings are added, so @@ -24,33 +22,85 @@ DELETE FROM actor.org_unit_setting WHERE id >= 14; -- clear out the test workstation (just in case) DELETE FROM actor.workstation WHERE name = 'BR1-test-09-lp1198465_neg_balances.t'; --- Setup all LOST circs +-- Setup some LOST circs, and change copy status to LOST +UPDATE action.circulation SET + xact_start = '2014-05-14 08:39:13.070326-04', + due_date = '2014-05-21 23:59:59-04', + stop_fines_time = '2014-05-28 08:39:13.070326-04', + create_time = '2014-05-14 08:39:13.070326-04', + max_fine = '3.00', + stop_fines = 'LOST', + checkin_staff = NULL, + checkin_lib = NULL, + checkin_time = NULL, + checkin_scan_time = NULL +WHERE id IN (1,2,3,4,5,6,12,13,15); +UPDATE asset.copy SET status = 3 WHERE id IN (2,3,4,5,6,7,13,14,16); + +-- relative LOST circ +UPDATE action.circulation SET + xact_start = NOW() - '24 days'::interval, + due_date = (DATE(NOW() - '10 days'::interval) || ' 23:59:59')::TIMESTAMP, + stop_fines_time = NOW() - '3 days'::interval, + create_time = NOW() - '24 days'::interval, + max_fine = '5.00', + stop_fines = 'LOST', + checkin_staff = NULL, + checkin_lib = NULL, + checkin_time = NULL, + checkin_scan_time = NULL +WHERE id = 10; +UPDATE asset.copy SET status = 3 WHERE id = 11; + +-- Two recently LOST items for Case 10: Interval Testing (1 hour interval) +-- - Item 1: Lost, paid more than 1 hour later, to be returned LESS than 1 hour after payment (via perl test) +-- - Item 2: Lost, paid more than 1 hour later, to be returned MORE than 1 hour after payment (via perl test) +UPDATE action.circulation SET + create_time = NOW() - '1 week'::interval, + xact_start = NOW() - '1 week'::interval, + due_date = NOW() + '1 day'::interval, + stop_fines_time = NOW() - '3 hours'::interval, + max_fine = '3.00', + stop_fines = 'LOST', + checkin_staff = NULL, + checkin_lib = NULL, + checkin_time = NULL, + checkin_scan_time = NULL +WHERE id IN (8, 9); +UPDATE asset.copy SET status = 3 WHERE id IN (9, 10); + +-- non-lost circs, used for Amnesty Mode check-ins UPDATE action.circulation SET xact_start = '2014-05-14 08:39:13.070326-04', - due_date = '2014-05-21 23:59:59-04', - stop_fines_time = '2014-05-28 08:39:13.070326-04', - create_time = '2014-05-14 08:39:13.070326-04', - max_fine = '3.00', - stop_fines = 'LOST', - checkin_staff = NULL, - checkin_lib = NULL, - checkin_time = NULL, - checkin_scan_time = NULL -WHERE id >= 1 AND id <= 6; -UPDATE asset.copy SET status = 3 WHERE id >= 2 AND id <= 7; - --- Setup non-lost circ + due_date = '2014-05-21 23:59:59-04', + stop_fines_time = '2014-05-28 08:39:13.070326-04', + create_time = '2014-05-14 08:39:13.070326-04', + max_fine = '0.70', + stop_fines = 'MAXFINES', + checkin_staff = NULL, + checkin_lib = NULL, + checkin_time = NULL, + checkin_scan_time = NULL +WHERE id IN (7, 14, 16); +UPDATE asset.copy SET status = 1 WHERE id IN (8, 15, 17); + +-- Setup a non-lost, maxfines circ UPDATE action.circulation SET - checkin_staff = NULL, - checkin_lib = NULL, - checkin_time = NULL, - checkin_scan_time = NULL, - stop_fines = NULL, - stop_fines_time = NULL -WHERE id = 7; -UPDATE asset.copy SET status = 1 WHERE id = 8; - --- Setup other LOST and overdue fines + xact_start = '2014-05-14 08:39:13.070326-04', + due_date = '2014-05-21 23:59:59-04', + stop_fines_time = '2014-05-28 08:39:13.070326-04', + create_time = '2014-05-14 08:39:13.070326-04', + max_fine = '0.70', + stop_fines = 'MAXFINES', + checkin_staff = NULL, + checkin_lib = NULL, + checkin_time = NULL, + checkin_scan_time = NULL +WHERE id = 11; +UPDATE asset.copy SET status = 1 WHERE id = 12; + + +-- Create LOST and overdue fines INSERT INTO money.billing (id, xact, billing_ts, voided, voider, void_time, amount, billing_type, btype, note) VALUES (DEFAULT, 1, '2014-05-28 08:39:13.070326-04', false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), (DEFAULT, 2, '2014-05-28 08:39:13.070326-04', false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), @@ -71,39 +121,74 @@ INSERT INTO money.billing (id, xact, billing_ts, voided, voider, void_time, amou (DEFAULT, 7, '2014-05-25 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), (DEFAULT, 7, '2014-05-26 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), (DEFAULT, 7, '2014-05-27 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), - (DEFAULT, 7, '2014-05-28 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'); + (DEFAULT, 7, '2014-05-28 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 8, NOW() - '2 hours'::interval, false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), + (DEFAULT, 9, NOW() - '4 hours'::interval, false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), + (DEFAULT, 11, '2014-05-22 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 11, '2014-05-23 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 11, '2014-05-24 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 11, '2014-05-25 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 11, '2014-05-26 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 11, '2014-05-27 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 11, '2014-05-28 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-22 23:59:59-04', true, 1, '2014-05-28 08:39:13.070326-04', 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-23 23:59:59-04', true, 1, '2014-05-28 08:39:13.070326-04', 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-24 23:59:59-04', true, 1, '2014-05-28 08:39:13.070326-04', 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-25 23:59:59-04', true, 1, '2014-05-28 08:39:13.070326-04', 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-26 23:59:59-04', true, 1, '2014-05-28 08:39:13.070326-04', 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-27 23:59:59-04', true, 1, '2014-05-28 08:39:13.070326-04', 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-28 23:59:59-04', true, 1, '2014-05-28 08:39:13.070326-04', 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 12, '2014-05-28 08:39:13.070326-04', false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), + (DEFAULT, 13, '2014-05-28 08:39:13.070326-04', false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), + (DEFAULT, 14, '2014-05-22 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 14, '2014-05-23 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 14, '2014-05-24 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 14, '2014-05-25 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 14, '2014-05-26 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 14, '2014-05-27 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 14, '2014-05-28 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 15, '2014-05-28 08:39:13.070326-04', false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), + (DEFAULT, 16, '2014-05-22 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 16, '2014-05-23 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 16, '2014-05-24 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 16, '2014-05-25 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 16, '2014-05-26 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 16, '2014-05-27 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 16, '2014-05-28 23:59:59-04', false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + -- XACT 10 must be last, because we use CURRVAL() to put their IDs in the adjustment payments + (DEFAULT, 10, (DATE(NOW() - '9 days'::interval) || ' 23:59:59')::TIMESTAMP, false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 10, (DATE(NOW() - '8 days'::interval) || ' 23:59:59')::TIMESTAMP, false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 10, (DATE(NOW() - '7 days'::interval) || ' 23:59:59')::TIMESTAMP, false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 10, (DATE(NOW() - '6 days'::interval) || ' 23:59:59')::TIMESTAMP, false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 10, (DATE(NOW() - '5 days'::interval) || ' 23:59:59')::TIMESTAMP, false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 10, (DATE(NOW() - '4 days'::interval) || ' 23:59:59')::TIMESTAMP, false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 10, (DATE(NOW() - '3 days'::interval) || ' 23:59:59')::TIMESTAMP, false, NULL, NULL, 0.10, 'Overdue materials', 1, 'System Generated Overdue Fine'), + (DEFAULT, 10, NOW() - '3 days'::interval, false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'); --- Setup two recently LOST items for Case 10: Interval Testing --- - Item 1: Lost, paid more than 1 hour later, returned less than 1 hour after payment (via perl test) --- - Item 2: Lost, paid more than 1 hour later, returned more than 1 hour after payment (via perl test) -UPDATE action.circulation SET - create_time = NOW() - '1 week'::interval, - xact_start = NOW() - '1 week'::interval, - due_date = NOW() + '1 day'::interval, - stop_fines_time = NOW() - '3 hours'::interval, - max_fine = '3.00', - stop_fines = 'LOST', - checkin_staff = NULL, - checkin_lib = NULL, - checkin_time = NULL, - checkin_scan_time = NULL -WHERE id IN (8, 9); -UPDATE asset.copy SET status = 3 WHERE id IN (9, 10); -INSERT INTO money.billing (id, xact, billing_ts, voided, voider, void_time, amount, billing_type, btype, note) VALUES - (DEFAULT, 8, NOW() - '2 hours'::interval, false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'), - (DEFAULT, 9, NOW() - '4 hours'::interval, false, NULL, NULL, 50.00, 'Lost Materials', 3, 'SYSTEM GENERATED'); +INSERT INTO money.adjustment_payment (id, xact, payment_ts, voided, amount, note, amount_collected, accepting_usr, billing) VALUES + (DEFAULT, 10, NOW() - '3 days'::interval, false, 0.10, '', 0.10, 1, CURRVAL('money.billing_id_seq') - 7), + (DEFAULT, 10, NOW() - '3 days'::interval, false, 0.10, '', 0.10, 1, CURRVAL('money.billing_id_seq') - 6), + (DEFAULT, 10, NOW() - '3 days'::interval, false, 0.10, '', 0.10, 1, CURRVAL('money.billing_id_seq') - 5), + (DEFAULT, 10, NOW() - '3 days'::interval, false, 0.10, '', 0.10, 1, CURRVAL('money.billing_id_seq') - 4), + (DEFAULT, 10, NOW() - '3 days'::interval, false, 0.10, '', 0.10, 1, CURRVAL('money.billing_id_seq') - 3), + (DEFAULT, 10, NOW() - '3 days'::interval, false, 0.10, '', 0.10, 1, CURRVAL('money.billing_id_seq') - 2), + (DEFAULT, 10, NOW() - '3 days'::interval, false, 0.10, '', 0.10, 1, CURRVAL('money.billing_id_seq') - 1); -INSERT INTO money.payment (id, xact, payment_ts, voided, amount, note) VALUES - (DEFAULT, 8, NOW() - '30 minutes'::interval, false, 50.00, 'LOST payment'), - (DEFAULT, 9, NOW() - '2 hours'::interval, false, 50.00, 'LOST payment'); +INSERT INTO money.cash_payment (id, xact, payment_ts, voided, amount, note, amount_collected, accepting_usr, cash_drawer) VALUES + (DEFAULT, 8, NOW() - '30 minutes'::interval, false, 50.00, 'LOST payment', 50.00, 1, 51), + (DEFAULT, 9, NOW() - '2 hours'::interval, false, 50.00, 'LOST payment', 50.00, 1, 51), + (DEFAULT, 10, NOW() - '2 days'::interval, false, 10.00, 'Partial LOST payment', 10.00, 1, 51); -- if rerunning, make sure our mangled bills have the right total in the summary UPDATE money.materialized_billable_xact_summary SET balance_owed = 50.00 - WHERE id >=1 AND id <= 6; + WHERE id IN (1,2,3,4,5,6,12,13,15); UPDATE money.materialized_billable_xact_summary SET balance_owed = 0.70 - WHERE id = 7; + WHERE id IN (7, 14, 16); UPDATE money.materialized_billable_xact_summary SET balance_owed = 0.00 - WHERE id IN (8, 9); - + WHERE id IN (8, 9); +UPDATE money.materialized_billable_xact_summary SET balance_owed = 40.00 + WHERE id = 10; +UPDATE money.materialized_billable_xact_summary SET balance_owed = 0.70 + WHERE id = 11; COMMIT; -- 2.43.2