Bugzilla – Attachment 112977 Details for
Bug 20125
Add a cron script to claim late orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20125: Take into account new table aqorders_claims
Bug-20125-Take-into-account-new-table-aqordersclai.patch (text/plain), 2.85 KB, created by
Alex Arnaud
on 2020-11-04 08:57:55 UTC
(
hide
)
Description:
Bug 20125: Take into account new table aqorders_claims
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2020-11-04 08:57:55 UTC
Size:
2.85 KB
patch
obsolete
>From 9dff9f85677b7d1f2c1bf1f6d246176533f1cd7b Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 4 Nov 2020 09:57:14 +0100 >Subject: [PATCH] Bug 20125: Take into account new table aqorders_claims > >--- > misc/cronjobs/ordersClaim.pl | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > >diff --git a/misc/cronjobs/ordersClaim.pl b/misc/cronjobs/ordersClaim.pl >index 776dbf3..bec1a72 100755 >--- a/misc/cronjobs/ordersClaim.pl >+++ b/misc/cronjobs/ordersClaim.pl >@@ -39,6 +39,7 @@ use Pod::Usage; > > use C4::Letters; > use C4::Acquisition; >+use Koha::Acquisition::Orders; > > =head1 NAME > >@@ -73,6 +74,8 @@ Default is 1; > > =back > >+=cut >+ > my $help; > my $delay; > my $claimed_for = 0; >@@ -89,11 +92,11 @@ GetOptions( > > pod2usage(1) if $help; > >-my @lateorders = GetLateOrders( ($delay) ); >+my @lateorders = Koha::Acquisition::Orders->filter_by_lates({ delay => $delay }); > > # Sort orders by basket > my $baskets_orders; >-push @{ $baskets_orders->{ $_->{basketno} } }, $_->{ordernumber} for @lateorders; >+push @{ $baskets_orders->{ $_->basketno } }, $_->ordernumber for @lateorders; > > while (my ($basketno, $orderids) = each %$baskets_orders) { > my $schema = Koha::Database->new->schema; >@@ -117,13 +120,16 @@ while (my ($basketno, $orderids) = each %$baskets_orders) { > > my $orderids_str = join(',', ('?') x @$orderids); > my $orders = $dbh->selectall_arrayref(qq{ >- SELECT aqorders.*, aqbasket.*, biblio.* >+ SELECT aqorders.*, aqbasket.*, biblio.*, >+ COUNT(aqorders_claims.claimed_on) AS claims_count, >+ MAX(aqorders_claims.claimed_on) AS last_claim > FROM aqorders > LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber > LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno >+ LEFT JOIN aqorders_claims ON aqorders.ordernumber = aqorders_claims.ordernumber > WHERE aqorders.ordernumber IN ($orderids_str) >- AND aqorders.claims_count < $max_claims >- AND (aqorders.claimed_date IS NULL or aqorders.claimed_date <= DATE_SUB(CAST(now() AS date),INTERVAL $claimed_for DAY)) >+ HAVING claims_count <= $max_claims >+ AND (last_claim IS NULL or last_claim <= DATE_SUB(CAST(now() AS date),INTERVAL $claimed_for DAY)) > }, {Slice => {}}, @$orderids); > > next unless @$orders; >@@ -154,13 +160,5 @@ while (my ($basketno, $orderids) = each %$baskets_orders) { > > continue unless $id; > >- my $today = Koha::DateUtils::dt_from_string; >- foreach my $o ( @$orders ) { >- my $order = $schema->resultset('Aqorder')->find($o->{ordernumber}); >- my $count = $order->get_column('claims_count') || 0; >- $order->set_columns({ >- claimed_date => $today->ymd, >- claims_count => $count+1 >- })->update_or_insert; >- } >+ Koha::Acquisition::Orders->find($_->{ordernumber})->claim() for @$orders; > } >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20125
:
71139
|
71274
|
74767
|
74837
|
74838
|
74839
| 112977 |
112981