return $grace_period;
}
+# check if a circulation transaction can be closed
+# takes a CStoreEditor and a circ transaction.
+# Returns 1 if the circ should be closed, 0 if not.
+sub can_close_circ {
+ my ($class, $e, $circ) = @_;
+ my $can_close = 0;
+
+ my $reason = $circ->stop_fines;
+
+ # We definitely want to close if this circulation was
+ # checked in or renewed.
+ if ($circ->checkin_time) {
+ $can_close = 1;
+ } elsif ($reason eq OILS_STOP_FINES_LOST) {
+ # Check the copy circ_lib to see if they close
+ # transactions when lost are paid.
+ my $copy = $e->retrieve_asset_copy($circ->target_copy);
+ if ($copy) {
+ $can_close = !$U->is_true(
+ $U->ou_ancestor_setting_value(
+ $copy->circ_lib,
+ 'circ.lost.xact_open_on_zero',
+ $e
+ )
+ );
+ }
+ }
+ return $can_close;
+}
+
1;
$credit += $cred;
my $circ = $e->retrieve_action_circulation($transid);
- if(!$circ || $circ->stop_fines) {
- # If this is a circulation, we can't close the transaction
- # unless stop_fines is set.
+ # Whether or not we close the transaction. We definitely
+ # close is no circulation transaction is present,
+ # otherwise we check if the circulation is in a state that
+ # allows itself to be closed.
+ if (!$circ || OpenILS::Application::Circ::CircCommon->can_close_circ($e, $circ)) {
$trans = $e->retrieve_money_billable_transaction($transid);
$trans->xact_finish("now");
if (!$e->update_money_billable_transaction($trans)) {
'bool'
);
+INSERT INTO config.org_unit_setting_type
+ (name, grp, label, description, datatype)
+ VALUES (
+ 'circ.lost.xact_open_on_zero',
+ 'finance',
+ oils_i18n_gettext(
+ 'circ.lost.xact_open_on_zero',
+ 'Leave transaction open when lost balance equals zero',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'circ.lost.xact_open_on_zero',
+ 'Leave transaction open when lost balance equals zero. This leaves the lost copy on the patron record when it is paid',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+ );
--- /dev/null
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type
+ (name, grp, label, description, datatype)
+ VALUES (
+ 'circ.lost.xact_open_on_zero',
+ 'finance',
+ oils_i18n_gettext(
+ 'circ.lost.xact_open_on_zero',
+ 'Leave transaction open when lost balance equals zero',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'circ.lost.xact_open_on_zero',
+ 'Leave transaction open when lost balance equals zero. This leaves the lost copy on the patron record when it is paid',
+ 'coust',
+ 'description'
+ ),
+ 'bool'
+ );
+
+COMMIT;