[open-ils-commits] r12411 - in trunk/Open-ILS: src/perlmods/OpenILS/Application src/sql/Pg xul/staff_client/server/admin (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Mar 4 18:49:25 EST 2009
Author: erickson
Date: 2009-03-04 18:49:25 -0500 (Wed, 04 Mar 2009)
New Revision: 12411
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
Log:
plugged in charge-on-damaged logic, org settings, and billing type
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm 2009-03-04 22:45:57 UTC (rev 12410)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm 2009-03-04 23:49:25 UTC (rev 12411)
@@ -872,16 +872,32 @@
);
sub mark_item {
- my( $self, $conn, $auth, $copy_id ) = @_;
+ my( $self, $conn, $auth, $copy_id, $args ) = @_;
my $e = new_editor(authtoken=>$auth, xact =>1);
- return $e->event unless $e->checkauth;
+ return $e->die_event unless $e->checkauth;
+ $args ||= {};
+ my $copy = $e->retrieve_asset_copy([
+ $copy_id,
+ {flesh => 1, flesh_fields => {'acp' => ['call_number']}}])->[0]
+ or return $e->die_event;
+
+ my $owning_lib =
+ ($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ?
+ $copy->circ_lib : $copy->call_number->owning_lib;
+
+ return $e->die_event unless $e->allowed('UPDATE_COPY', $owning_lib);
+
+
my $perm = 'MARK_ITEM_MISSING';
my $stat = OILS_COPY_STATUS_MISSING;
if( $self->api_name =~ /damaged/ ) {
$perm = 'MARK_ITEM_DAMAGED';
$stat = OILS_COPY_STATUS_DAMAGED;
+ my $evt = handle_mark_damaged($e, $copy, $owning_lib, $args);
+ return $evt if $evt;
+
} elsif ( $self->api_name =~ /bindery/ ) {
$perm = 'MARK_ITEM_BINDERY';
$stat = OILS_COPY_STATUS_BINDERY;
@@ -902,15 +918,13 @@
$stat = OILS_COPY_STATUS_DISCARD;
}
- my $copy = $e->retrieve_asset_copy($copy_id)
- or return $e->event;
+
$copy->status($stat);
$copy->edit_date('now');
$copy->editor($e->requestor->id);
- $e->update_asset_copy($copy) or return $e->event;
+ $e->update_asset_copy($copy) or return $e->die_event;
-
my $holds = $e->search_action_hold_request(
{
current_copy => $copy->id,
@@ -927,11 +941,65 @@
return 1;
}
+sub handle_mark_damaged {
+ my($e, $copy, $owning_lib, $args) = @_;
+ my $apply = $args->{apply_fines} || '';
+ return undef if $apply eq 'noapply';
+ # grab the last circulation
+ my $circ = $e->search_action_circulation([
+ { target_copy => $copy->id},
+ { limit => 1,
+ order_by => {circ => "xact_start DESC"},
+ flesh => 1,
+ flesh_fields => {circ => ['target_copy', 'usr']}
+ }
+ ])->[0];
+ return undef unless $circ;
+ my $charge_price = $U->ou_ancestor_setting_value(
+ $owning_lib, 'circ.charge_on_damaged', $e);
+ my $proc_fee = $U->ou_ancestor_setting_value(
+ $owning_lib, 'circ.damaged_item_processing_fee', $e) || 0;
+
+ return undef unless $charge_price or $proc_fee;
+
+ my $copy_price = ($charge_price) ? $U->get_copy_price($e, $copy) : 0;
+ my $total = $copy_price + $proc_fee;
+ my $apply = $args->{apply_fines};
+
+ if($apply) {
+
+ if($charge_price and $copy_price) {
+ my $evt = OpenILS::Application::Circ::CircCommon->create_bill(
+ $e, $copy_price, 7, 'Damaged Item', $circ->id);
+ return $evt if $evt;
+ }
+
+ if($proc_fee) {
+ my $evt = OpenILS::Application::Circ::CircCommon->create_bill(
+ $e, $proc_fee, 8, 'Damaged Item Processing Fee', $circ->id);
+ return $evt if $evt;
+ }
+
+ my $evt = OpenILS::Application::Circ::CircCommon->reopen_xact($e, $circ->id);
+ return $evt if $evt;
+ return undef;
+
+ } else {
+ return new OpenILS::Event->('DAMAGE_CHARGE',
+ {usr => $circ->usr->id, charge => $total});
+ }
+}
+
+
+
+
+
+
# ----------------------------------------------------------------------
__PACKAGE__->register_method(
method => 'magic_fetch',
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2009-03-04 22:45:57 UTC (rev 12410)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2009-03-04 23:49:25 UTC (rev 12411)
@@ -864,6 +864,10 @@
( 5, oils_i18n_gettext(5, 'System: Deposit', 'cbt', 'name'), 1);
INSERT INTO config.billing_type (id, name, owner) VALUES
( 6, oils_i18n_gettext(6, 'System: Rental', 'cbt', 'name'), 1);
+INSERT INTO config.billing_type (id, name, owner) VALUES
+ ( 7, oils_i18n_gettext(7, 'Damaged Item', 'cbt', 'name'), 1);
+INSERT INTO config.billing_type (id, name, owner) VALUES
+ ( 8, oils_i18n_gettext(8, 'Damaged Item Processing Fee', 'cbt', 'name'), 1);
SELECT SETVAL('config.billing_type_id_seq'::TEXT, 100);
Modified: trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml 2009-03-04 22:45:57 UTC (rev 12410)
+++ trunk/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml 2009-03-04 23:49:25 UTC (rev 12411)
@@ -154,6 +154,14 @@
'circ.void_item_billing_on_lost_return_before_interval' : {
label : '&staff.server.admin.org_settings.circ.void_item_billing_on_lost_return_before_interval;',
desc : '&staff.server.admin.org_settings.circ.void_item_billing_on_lost_return_before_interval.desc;',
+ },
+ 'circ.charge_on_damaged' : {
+ label : '&staff.server.admin.org_settings.circ.charge_on_damaged;',
+ desc : '&staff.server.admin.org_settings.circ.charge_on_damaged.desc;',
+ },
+ 'circ.damaged_item_processing_fee' : {
+ label : '&staff.server.admin.org_settings.circ.damaged_item_processing_fee;',
+ desc : '&staff.server.admin.org_settings.circ.damaged_item_processing_fee.desc;',
}
};
</script>
More information about the open-ils-commits
mailing list