[open-ils-commits] SPAM: r10462 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Aug 27 11:58:24 EDT 2008
Author: erickson
Date: 2008-08-27 11:58:21 -0400 (Wed, 27 Aug 2008)
New Revision: 10462
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
i was not providing explicit sort to cstore call, so limit/offset was not guaranteed to return unique results with each subsequent call. falling back to fetching id list up front cuz its just more obvious what's going on
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2008-08-27 14:38:21 UTC (rev 10461)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm 2008-08-27 15:58:21 UTC (rev 10462)
@@ -617,14 +617,19 @@
my $po = $e->retrieve_acq_purchase_order($po_id) or return $e->die_event;
# XXX which perms?
- my $o = 0;
- while(my $li = $e->search_acq_lineitem([
- { purchase_order => $po_id},
- { offset => $o++,
- limit => 1,
- flesh => 1,
- flesh_fields => {jub => ['attributes']}}])->[0]) {
+ my $li_ids = $e->search_acq_lineitem(
+ {purchase_order => $po_id},
+ {idlist => 1}
+ );
+ for my $li_id (@$li_ids) {
+ my $li = $e->retrieve_acq_lineitem([
+ $li_id,
+ { flesh => 1,
+ flesh_fields => {jub => ['attributes']},
+ }
+ ]);
+
my ($price, $ptype) = get_li_price($li);
unless($price) {
$e->rollback;
@@ -636,17 +641,23 @@
return OpenILS::Event->new('ACQ_LINEITEM_NO_PROVIDER', payload => $li->id);
}
- my $oo = 0;
- while(my $lid = $e->search_acq_lineitem_detail([
- { lineitem => $li->id},
- { offset => $oo++,
- limit => 1,
- flesh => 1,
- flesh_fields => {acqlid => ['fund']}}])->[0]) {
+ my $lid_ids = $e->search_acq_lineitem_detail(
+ {lineitem => $li->id},
+ {idlist=>1}
+ );
+ for my $lid_id (@$lid_ids) {
+ my $lid = $e->retrieve_acq_lineitem_detail([
+ $lid_id,
+ { flesh => 1,
+ flesh_fields => {acqlid => ['fund']}
+ }
+ ]);
+
my $debit = Fieldmapper::acq::fund_debit->new;
$debit->fund($lid->fund->id);
$debit->origin_amount($price);
+
if($ptype == 2) { # price from vendor
$debit->origin_currency_type($li->provider->currency_type);
$debit->amount(currency_conversion_impl(
More information about the open-ils-commits
mailing list