View | Details | Raw Unified | Return to bug 10869
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-2 / +2 lines)
Lines 1285-1291 sub NewOrder { Link Here
1285
1285
1286
=head3 NewOrderItem
1286
=head3 NewOrderItem
1287
1287
1288
  &NewOrderItem();
1288
  &NewOrderItem( $itemnumber, $ordernumber );
1289
1289
1290
=cut
1290
=cut
1291
1291
Lines 1762-1767 cancelled. Link Here
1762
1762
1763
sub DelOrder {
1763
sub DelOrder {
1764
    my ($ordernumber,$biblionumber) = @_;
1764
    my ($ordernumber,$biblionumber) = @_;
1765
    return if !$ordernumber;
1765
    my $dbh = C4::Context->dbh;
1766
    my $dbh = C4::Context->dbh;
1766
    my $query = "
1767
    my $query = "
1767
        UPDATE aqorders
1768
        UPDATE aqorders
Lines 1770-1776 sub DelOrder { Link Here
1770
    ";
1771
    ";
1771
    my $sth = $dbh->prepare($query);
1772
    my $sth = $dbh->prepare($query);
1772
    $sth->execute($ordernumber );
1773
    $sth->execute($ordernumber );
1773
    $sth->finish;
1774
    if ($biblionumber) {
1774
    if ($biblionumber) {
1775
        my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1775
        my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1776
        foreach my $itemnumber (@itemnumbers){
1776
        foreach my $itemnumber (@itemnumbers){
(-)a/t/db_dependent/Acquisition.t (-2 / +54 lines)
Lines 7-14 use Modern::Perl; Link Here
7
use POSIX qw(strftime);
7
use POSIX qw(strftime);
8
8
9
use C4::Bookseller qw( GetBookSellerFromId );
9
use C4::Bookseller qw( GetBookSellerFromId );
10
use C4::Items qw (AddItem GetItem);
11
use C4::Branch qw (ModBranch);
10
12
11
use Test::More tests => 62;
13
use Test::More tests => 67;
12
14
13
BEGIN {
15
BEGIN {
14
    use_ok('C4::Acquisition');
16
    use_ok('C4::Acquisition');
Lines 223-226 is($order3->{'quantityreceived'}, 2, 'Order not split up'); Link Here
223
is($order3->{'quantity'}, 2, '2 items on order');
225
is($order3->{'quantity'}, 2, '2 items on order');
224
is($order3->{'budget_id'}, $budgetid2, 'Budget has changed');
226
is($order3->{'budget_id'}, $budgetid2, 'Budget has changed');
225
227
228
#
229
# test DelOrder
230
# use:
231
# &DelOrder($ordernumber,$biblionumber);
232
233
# create 3 items on the same record and link 2 of them to the order
234
235
# Add a branch
236
my $b1 = {
237
    add            => 1,
238
    branchcode     => 'BRA',
239
    branchname     => 'BranchA',
240
    branchaddress1 => 'adr1A',
241
    branchaddress2 => 'adr2A',
242
    branchaddress3 => 'adr3A',
243
    branchzip      => 'zipA',
244
    branchcity     => 'cityA',
245
    branchstate    => 'stateA',
246
    branchcountry  => 'countryA',
247
    branchphone    => 'phoneA',
248
    branchfax      => 'faxA',
249
    branchemail    => 'emailA',
250
    branchurl      => 'urlA',
251
    branchip       => 'ipA',
252
    branchprinter  => undef,
253
    branchnotes    => 'noteA',
254
    opac_info      => 'opacA'
255
};
256
ModBranch($b1);
257
258
my ($item_bibnum1, $item_bibitemnum1, $itemnumber1) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2);
259
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2);
260
my ($item_bibnum3, $item_bibitemnum3, $itemnumber3) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2);
261
NewOrderItem ($itemnumber1, $ordernumber3);
262
NewOrderItem ($itemnumber2, $ordernumber3);
263
264
# If no ordernumber is passed, the function returns undef and does not try to update database
265
my $return_DelOrder = DelOrder ();
266
is($return_DelOrder , undef, 'DelOrder returns undef with no param');
267
# Cancel the order with the given order, by filling the datecancellationprinted and orderstatus fields.
268
DelOrder ($ordernumber3,$biblionumber2);
269
$order3 = GetOrder( $ordernumber3 );
270
ok(($order3->{'orderstatus'} eq 'cancelled')&& (defined $order3->{'datecancellationprinted'}),'DelOrders update orderstatus and fill datecancellationprinted fields');
271
272
# All the items linked with that order are deleted.
273
is(scalar GetItemnumbersFromOrder($ordernumber3), 0, 'DelOrders delete items linked with cancelled order in aqorders_items table');
274
ok(!defined GetItem($itemnumber1) && !defined GetItem($itemnumber2),  "DelOrder deletes items linked with order in items table");
275
276
# Other items (created manually) are not deleted.
277
is(GetItem($itemnumber3)->{biblionumber},$biblionumber2, "DelOrder does not delete item created manually");
278
226
$dbh->rollback;
279
$dbh->rollback;
227
- 

Return to bug 10869