Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 013fdb49

Von Sven Schöling vor etwa 3 Jahren hinzugefügt

  • ID 013fdb495a2cac764df23c9ec0b455ffc5b9323e
  • Vorgänger a14dfdf8
  • Nachfolger 45ea642b

do: beistell und rma Lieferscheine

Unterschiede anzeigen:

SL/DO.pm
42 42
use SL::Common;
43 43
use SL::CVar;
44 44
use SL::DB::DeliveryOrder;
45
use SL::DB::DeliveryOrder::TypeData qw(:types);
45 46
use SL::DB::Status;
46 47
use SL::DBUtils;
47 48
use SL::Helper::ShippedQty;
......
90 91
       LEFT JOIN department dep ON (dord.department_id = dep.id)
91 92
|;
92 93

  
93
  push @where, ($form->{type} eq 'sales_delivery_order' ? '' : 'NOT ') . qq|COALESCE(dord.is_sales, FALSE)|;
94
  if (SL::DB::DeliveryOrder::TypeData::is_valid_type($form->{type})) {
95
    push @where, qq|dord.order_type = ?|;
96
    push @values, $form->{type};
97
  }
94 98

  
95 99
  if ($form->{department_id}) {
96 100
    push @where,  qq|dord.department_id = ?|;
......
308 312
  $form->{employee_id} = (split /--/, $form->{employee})[1] if !$form->{employee_id};
309 313
  $form->get_employee($dbh) unless ($form->{employee_id});
310 314

  
311
  my $ml = ($form->{type} eq 'sales_delivery_order') ? 1 : -1;
312

  
313 315
  my (@processed_doi, @processed_dois);
314 316

  
315 317
  if ($form->{id}) {
......
328 330
    $query = qq|SELECT nextval('id')|;
329 331
    ($form->{id}) = selectrow_query($form, $dbh, $query);
330 332

  
331
    $query = qq|INSERT INTO delivery_orders (id, donumber, employee_id, currency_id, taxzone_id) VALUES (?, '', ?, (SELECT currency_id FROM defaults LIMIT 1), ?)|;
332
    do_query($form, $dbh, $query, $form->{id}, conv_i($form->{employee_id}), $form->{taxzone_id});
333
    $query = qq|INSERT INTO delivery_orders (id, donumber, employee_id, currency_id, taxzone_id, order_type) VALUES (?, '', ?, (SELECT currency_id FROM defaults LIMIT 1), ?, ?)|;
334
    do_query($form, $dbh, $query, $form->{id}, conv_i($form->{employee_id}), $form->{taxzone_id}, $form->{type});
333 335
  }
334 336

  
335 337
  my $project_id;
......
365 367
SQL
366 368
  my $h_item_stock = prepare_query($form, $dbh, $q_item_stock);
367 369

  
368
  my $in_out       = $form->{type} =~ /^sales/ ? 'out' : 'in';
370
  my $in_out       = transfer_direction($form->{type});
369 371

  
370 372
  for my $i (1 .. $form->{rowcount}) {
371 373
    next if (!$form->{"id_$i"});
......
515 517
         shippingpoint = ?, shipvia = ?, notes = ?, intnotes = ?, closed = ?,
516 518
         delivered = ?, department_id = ?, language_id = ?, shipto_id = ?,
517 519
         globalproject_id = ?, employee_id = ?, salesman_id = ?, cp_id = ?, transaction_description = ?,
518
         is_sales = ?, taxzone_id = ?, taxincluded = ?, payment_id = ?, currency_id = (SELECT id FROM currencies WHERE name = ?),
520
         is_sales = ?, order_type = ?, taxzone_id = ?, taxincluded = ?, payment_id = ?, currency_id = (SELECT id FROM currencies WHERE name = ?),
519 521
         delivery_term_id = ?
520 522
       WHERE id = ?|;
521 523

  
......
529 531
             conv_i($form->{globalproject_id}), conv_i($form->{employee_id}),
530 532
             conv_i($form->{salesman_id}), conv_i($form->{cp_id}),
531 533
             $form->{transaction_description},
532
             $form->{type} =~ /^sales/ ? 't' : 'f',
534
             is_customer($form->{type}), SL::DB::DeliveryOrder::TypeData::validate_type($form->{type}),
533 535
             conv_i($form->{taxzone_id}), $form->{taxincluded} ? 't' : 'f', conv_i($form->{payment_id}), $form->{currency},
534 536
             conv_i($form->{delivery_term_id}),
535 537
             conv_i($form->{id}));
......
559 561
  delete $form->{convert_from_oe_ids};
560 562
  unless ($::instance_conf->get_shipped_qty_require_stock_out) {
561 563
    $self->mark_orders_if_delivered('do_id' => $form->{id},
562
                                    'type'  => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase');
564
                                    'type'  => customervendor($form->{type}) ? 'sales' : 'purchase');
563 565
  }
564 566

  
565 567
  $form->{saved_donumber} = $form->{donumber};
......
735 737
         dord.itime, dord.mtime,
736 738
         dord.globalproject_id, dord.delivered, dord.transaction_description,
737 739
         dord.taxzone_id, dord.taxincluded, dord.payment_id, (SELECT cu.name FROM currencies cu WHERE cu.id=dord.currency_id) AS currency,
738
         dord.delivery_term_id, dord.itime::DATE AS insertdate
740
         dord.delivery_term_id, dord.itime::DATE AS insertdate, dord.order_type as type
739 741
       FROM delivery_orders dord
740 742
       JOIN ${vc} cv ON (dord.${vc}_id = cv.id)
741 743
       LEFT JOIN employee e ON (dord.employee_id = e.id)
......
849 851
  }
850 852

  
851 853
  if ($mode eq 'single') {
852
    my $in_out = $form->{type} =~ /^sales/ ? 'out' : 'in';
854
    my $in_out = transfer_direction($form->{type});
853 855

  
854 856
    $query =
855 857
      qq|SELECT id as delivery_order_items_stock_id, qty, unit, bin_id,
......
939 941
                           (SELECT description FROM warehouse WHERE id = ?) AS warehouse|;
940 942
  my $h_bin_wh = prepare_query($form, $dbh, $q_bin_wh);
941 943

  
942
  my $in_out   = $form->{type} =~ /^sales/ ? 'out' : 'in';
944
  my $in_out   = transfer_direction($form->{type});
943 945

  
944 946
  my $num_si   = 0;
945 947

  
......
1265 1267

  
1266 1268
  if ($::instance_conf->get_shipped_qty_require_stock_out) {
1267 1269
    $self->mark_orders_if_delivered('do_id' => $form->{id},
1268
                                    'type'  => $form->{type} eq 'sales_delivery_order' ? 'sales' : 'purchase');
1270
                                    'type'  => is_customer($form->{type}) ? 'sales' : 'purchase');
1269 1271
  }
1270 1272

  
1271 1273
  $main::lxdebug->leave_sub();
......
1291 1293
  return $delivered ? 1 : 0;
1292 1294
}
1293 1295

  
1296
sub customervendor {
1297
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "customervendor");
1298
}
1299

  
1300
sub is_customer {
1301
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "is_customer");
1302
}
1303

  
1304
sub transfer_direction {
1305
  SL::DB::DeliveryOrder::TypeData::get3($_[0], "properties", "transfer");
1306
}
1307

  
1294 1308
1;

Auch abrufbar als: Unified diff