From: miker Date: Wed, 3 Dec 2008 17:04:22 +0000 (+0000) Subject: add in-db billing type support X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9e5534a48ac7b088a246cfb1bd45b607afed228d;p=Evergreen.git add in-db billing type support git-svn-id: svn://svn.open-ils.org/ILS/trunk@11389 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 21b9dcc9fc..fe80332283 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3385,17 +3385,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 93db5b5a06..f33f5c6079 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -293,14 +293,14 @@ sub new_set_circ_lost { my $price = $U->get_copy_price($e, $copy, $copy->call_number); if( $price > 0 ) { - my $evt = create_bill($e, $price, 'Lost Materials', $circ->id); + my $evt = create_bill($e, $price, 3, 'Lost Materials', $circ->id); return $evt if $evt; } # --------------------------------------------------------------------- # if there is a processing fee, charge that too if( $proc_fee > 0 ) { - my $evt = create_bill($e, $proc_fee, 'Lost Materials Processing Fee', $circ->id); + my $evt = create_bill($e, $proc_fee, 4, 'Lost Materials Processing Fee', $circ->id); return $evt if $evt; } @@ -347,7 +347,7 @@ sub reopen_xact { sub create_bill { - my( $e, $amount, $type, $xactid ) = @_; + my( $e, $amount, $btype, $type, $xactid ) = @_; $logger->info("The system is charging $amount [$type] on xact $xactid"); @@ -357,6 +357,7 @@ sub create_bill { $bill->xact($xactid); $bill->amount($amount); $bill->billing_type($type); + $bill->btype($btype); $bill->note('SYSTEM GENERATED'); $e->create_money_billing($bill) or return $e->die_event; @@ -374,7 +375,7 @@ sub void_overdues { my $bill_search = { xact => $circ->id, - billing_type => OILS_BILLING_TYPE_OVERDUE_MATERIALS + btype => 1 }; if( $backdate ) { diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index a61b67a30b..24f7fd8b75 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -1194,12 +1194,15 @@ sub apply_deposit_fee { my $bill = Fieldmapper::money::billing->new; my $amount = $copy->deposit_amount; my $billing_type; + my $btype; if($self->is_deposit) { $billing_type = OILS_BILLING_TYPE_DEPOSIT; + $btype = 5; $self->deposit_billing($bill); } else { $billing_type = OILS_BILLING_TYPE_RENTAL; + $btype = 6; $self->rental_billing($bill); } @@ -1207,6 +1210,7 @@ sub apply_deposit_fee { $bill->amount($amount); $bill->note(OILS_BILLING_NOTE_SYSTEM); $bill->billing_type($billing_type); + $bill->btype($btype); $self->editor->create_money_billing($bill) or $self->bail_on_events($self->editor->event); $logger->info("circulator: charged $amount on checkout with billing type $billing_type"); @@ -1758,7 +1762,7 @@ sub check_circ_deposit { my $self = shift; return unless $self->circ; my $deposit = $self->editor->search_money_billing( - { billing_type => OILS_BILLING_TYPE_DEPOSIT, + { btype => 5, xact => $self->circ->id, voided => 'f' }, {idlist => 1})->[0]; @@ -2139,7 +2143,7 @@ sub checkin_handle_backdate { { billing_ts => { '>=' => $bd }, xact => $self->circ->id, - billing_type => OILS_BILLING_TYPE_OVERDUE_MATERIALS + btype => 1 } ); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm b/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm index 09cf561b02..050a9d157e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm @@ -435,6 +435,7 @@ sub add_collections_fee { my $bill = Fieldmapper::money::billing->new; $bill->note($fee_note); $bill->xact($xact->id); + $bill->btype(2); $bill->billing_type(OILS_BILLING_TYPE_COLLECTION_FEE); $bill->amount($fee_amount); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm index 5e32636251..ab21f8495d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm @@ -79,7 +79,8 @@ package money::billing; use base qw/money/; __PACKAGE__->table('money_billing'); __PACKAGE__->columns(Primary => 'id'); -__PACKAGE__->columns(Essential => qw/xact amount billing_ts billing_type note voided voider void_time/); +__PACKAGE__->columns(Essential => qw/xact amount billing_ts billing_type note + voided voider void_time btype/); #------------------------------------------------------------------------------- package money::payment; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index 8068e45416..439b88923c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -640,7 +640,7 @@ sub generate_fines { my @fines = money::billing->search_where( { xact => $c->id, - billing_type => 'Overdue materials', + btype => 1, billing_ts => { '>' => $c->due_date } }, { order_by => 'billing_ts DESC'} ); @@ -752,6 +752,7 @@ sub generate_fines { { xact => ''.$c->id, note => "System Generated Overdue Fine", billing_type => "Overdue materials", + btype => 1, amount => sprintf('%0.2f', $recuring_fine/100), billing_ts => $timestamptz, } diff --git a/Open-ILS/src/sql/Pg/080.schema.money.sql b/Open-ILS/src/sql/Pg/080.schema.money.sql index 34c2dab93e..a585865098 100644 --- a/Open-ILS/src/sql/Pg/080.schema.money.sql +++ b/Open-ILS/src/sql/Pg/080.schema.money.sql @@ -56,6 +56,7 @@ CREATE TABLE money.billing ( void_time TIMESTAMP WITH TIME ZONE, amount NUMERIC(6,2) NOT NULL, billing_type TEXT NOT NULL, + btype INT NOT NULL REFERENCES config.billing_type (id) ON DELETE RESTRICT, note TEXT ); CREATE INDEX m_b_xact_idx ON money.billing (xact); diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 27b7b45d59..129aa3c308 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -805,6 +805,21 @@ INSERT INTO actor.org_unit_type (id, name, opac_label, depth, parent) VALUES oils_i18n_gettext(5, 'Your Bookmobile', 'aout', 'opac_label'), 3, 3 ); SELECT SETVAL('actor.org_unit_type_id_seq'::TEXT, 100); +INSERT INTO config.billing_type (id, name, owner) VALUES + ( 1, oils_i18n_gettext(1, 'Overdue Materials', 'cbt', 'name'), 1); +INSERT INTO config.billing_type (id, name, owner) VALUES + ( 2, oils_i18n_gettext(2, 'Long Overdue Collection Fee', 'cbt', 'name'), 1); +INSERT INTO config.billing_type (id, name, owner) VALUES + ( 3, oils_i18n_gettext(3, 'Lost Materials', 'cbt', 'name'), 1); +INSERT INTO config.billing_type (id, name, owner) VALUES + ( 4, oils_i18n_gettext(4, 'Lost Materials Processing Fee', 'cbt', 'name'), 1); +INSERT INTO config.billing_type (id, name, owner) VALUES + ( 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); + +SELECT SETVAL('config.billing_type_id_seq'::TEXT, 100); + INSERT INTO actor.org_unit (id, parent_ou, ou_type, shortname, name) VALUES (1, NULL, 1, 'CONS', oils_i18n_gettext(1, 'Example Consortium', 'aou', 'name')); INSERT INTO actor.org_unit (id, parent_ou, ou_type, shortname, name) VALUES