[open-ils-commits] r16463 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu May 20 10:10:49 EDT 2010
Author: erickson
Date: 2010-05-20 10:10:47 -0400 (Thu, 20 May 2010)
New Revision: 16463
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
Log:
loosen the restrictions on exporting holdings / price data from uploaded records. It's no longer necessary to set every field in the holdings data just to import. if no quantity is defined, go ahead and pull the estimed price data (when present) to link it with the lineitem
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2010-05-20 05:21:39 UTC (rev 16462)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm 2010-05-20 14:10:47 UTC (rev 16463)
@@ -1293,6 +1293,7 @@
$org_path = [ reverse (@$org_path) ];
my $price;
+
my $idx = 1;
while(1) {
# create a lineitem detail for each copy in the data
@@ -1303,8 +1304,10 @@
# this takes the price of the last copy and uses it as the lineitem price
# need to determine if a given record would include different prices for the same item
- $price = $$compiled{price};
+ $price = $$compiled{estimated_price};
+ last unless $$compiled{quantity};
+
for(1..$$compiled{quantity}) {
my $lid = create_lineitem_detail($mgr,
lineitem => $li->id,
@@ -1346,43 +1349,40 @@
return 0;
};
- $compiled{quantity} ||= 1;
-
# ---------------------------------------------------------------------
# Fund
- my $code = $compiled{fund_code};
- return $killme->('no fund code provided') unless $code;
+ if(my $code = $compiled{fund_code}) {
- my $fund = $mgr->cache($base_org, "fund.$code");
- unless($fund) {
- # search up the org tree for the most appropriate fund
- for my $org (@$org_path) {
- $fund = $mgr->editor->search_acq_fund(
- {org => $org, code => $code, year => DateTime->now->year}, {idlist => 1})->[0];
- last if $fund;
+ my $fund = $mgr->cache($base_org, "fund.$code");
+ unless($fund) {
+ # search up the org tree for the most appropriate fund
+ for my $org (@$org_path) {
+ $fund = $mgr->editor->search_acq_fund(
+ {org => $org, code => $code, year => DateTime->now->year}, {idlist => 1})->[0];
+ last if $fund;
+ }
}
+ return $killme->("no fund with code $code at orgs [@$org_path]") unless $fund;
+ $compiled{fund} = $fund;
+ $mgr->cache($base_org, "fund.$code", $fund);
}
- return $killme->("no fund with code $code at orgs [@$org_path]") unless $fund;
- $compiled{fund} = $fund;
- $mgr->cache($base_org, "fund.$code", $fund);
# ---------------------------------------------------------------------
# Owning lib
- my $sn = $compiled{owning_lib};
- return $killme->('no owning_lib defined') unless $sn;
- my $org_id =
- $mgr->cache($base_org, "orgsn.$sn") ||
+ if(my $sn = $compiled{owning_lib}) {
+ my $org_id = $mgr->cache($base_org, "orgsn.$sn") ||
$mgr->editor->search_actor_org_unit({shortname => $sn}, {idlist => 1})->[0];
- return $killme->("invalid owning_lib defined: $sn") unless $org_id;
- $compiled{owning_lib} = $org_id;
- $mgr->cache($$org_path[0], "orgsn.$sn", $org_id);
+ return $killme->("invalid owning_lib defined: $sn") unless $org_id;
+ $compiled{owning_lib} = $org_id;
+ $mgr->cache($$org_path[0], "orgsn.$sn", $org_id);
+ }
# ---------------------------------------------------------------------
# Circ Modifier
+ my $code = $compiled{circ_modifier};
my $mod;
- $code = $compiled{circ_modifier};
if($code) {
@@ -1393,17 +1393,15 @@
} else {
# try the default
- $mod = get_default_circ_modifier($mgr, $base_org)
- or return $killme->('no circ_modifier defined');
+ $mod = get_default_circ_modifier($mgr, $base_org);
}
- $compiled{circ_modifier} = $mod;
+ $compiled{circ_modifier} = $mod if $mod;
# ---------------------------------------------------------------------
# Shelving Location
- my $name = $compiled{copy_location};
- if($name) {
+ if( my $name = $compiled{copy_location}) {
my $loc = $mgr->cache($base_org, "copy_loc.$name");
unless($loc) {
for my $org (@$org_path) {
More information about the open-ils-commits
mailing list