From: Chris Sharp Date: Thu, 6 Aug 2015 12:53:25 +0000 (-0400) Subject: adding the beginning of reset_po.pl X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4a65bc5c91fdc0087b5ebc185b11e659ba8248ac;p=contrib%2Fpines.git adding the beginning of reset_po.pl --- diff --git a/acq/reset_po.pl b/acq/reset_po.pl new file mode 100755 index 0000000..3f86eaf --- /dev/null +++ b/acq/reset_po.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +# Copyright (C) 2015 Georgia Public Library Service +# Chris Sharp +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# A script to reset an Evergreen Acquisitions purchase order. + +# Example workflow: +#begin; +#select id from action_trigger.event_output where id in (select template_output from action_trigger.event where event_def = 23 and target in (270, 271, 274, 275)); +#[record output IDs somewhere] +#delete from action_trigger.event where event_def = 23 and target in (270, 271, 274, 275); +#delete from action_trigger.event_output where id in (3020734, 3020735, 3020736, 3020733); +#[^^ recorded IDs] +#delete from acq.edi_message where purchase_order in (270, 271, 274, 275); +#update acq.purchase_order set state = 'pending', order_date = null where id in (270, 271, 274, 275); +#commit; + + +use warnings; +use strict; +use DBI; + +my @po_ids = @ARGV; +my $grab_output_ids = qq/select id from + action_trigger.event_output + where id in ( + select template_output + from action_trigger.event + where event_def = 23 + and target in (?) + )/; +my $delete_at_events = qq/delete from action_trigger.event where event_def = 23 and target in (?)/; +my $delete_at_outputs = qq/delete from action_trigger.event_output where id in (?)/; +my $delete_edi_messages = qq/delete from acq.edi_message where purchase_order in (?)/; +my $update_pos = qq/update acq.purchase_order set state = 'pending', order_date = null where id in (?)/; + + +foreach my $id (@po_ids) { + print "$id, "; +} + +#my $dbh = DBI->connect('DBI:Pg:'); +#my $sth = $dbh->prepare($grab_output_ids); +#$sth->execute(@po_ids);