Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9d07c34f

Von Bernd Bleßmann vor etwa 9 Jahren hinzugefügt

  • ID 9d07c34f5b429bfc118629d74b376479c37a8383
  • Vorgänger 40ebe601
  • Nachfolger 6d808fff

Auslagern in VK-Rechnung: Beim Buchen einer VK-Rechnung wird ausgelagert.

Todo: Es werden noch nicht alle Einstellungen berücksichtigt, die bestimmen,
wann von welchem Lager/Lagerplatz ausgelagert wird.

Unterschiede anzeigen:

SL/IS.pm
1291 1291
  return $rc;
1292 1292
}
1293 1293

  
1294
sub transfer_out {
1295
  $::lxdebug->enter_sub;
1296

  
1297
  my ($self, $form) = @_; 
1298

  
1299
  my @transfers;
1300

  
1301
  foreach my $i (1 .. $form->{rowcount}) {
1302
    next if !$form->{"id_$i"};
1303
    my ($wh_id, $bin_id) = _determine_wh_and_bin($::instance_conf, $form->{"id_$i"});
1304

  
1305
    if ($wh_id && $bin_id) {
1306
      push @transfers, {
1307
        'parts_id'         => $form->{"id_$i"},
1308
        'qty'              => $form->{"qty_$i"},
1309
        'unit'             => $form->{"unit_$i"},
1310
        'transfer_type'    => 'shipped',
1311
        'src_warehouse_id' => $wh_id,
1312
        'src_bin_id'       => $bin_id,
1313
        'project_id'       => $form->{"project_id_$i"},
1314
        'invoice_id'       => $form->{"invoice_id_$i"},
1315
      };
1316
    }
1317
  }
1318

  
1319
  require SL::WH;
1320
  WH->transfer(@transfers);
1321

  
1322
  $::lxdebug->leave_sub;
1323
  return 1;
1324
}
1325

  
1326
sub _determine_wh_and_bin {
1327
  $::lxdebug->enter_sub(2);
1328

  
1329
  my ($conf, $part_id) = @_;
1330

  
1331
  my $part = SL::DB::Part->new(id => $part_id)->load;
1332

  
1333
  if ($part->is_service && !$conf->get_transfer_default_services) {
1334
    $::lxdebug->leave_sub(2);
1335
    return;
1336
  }
1337
    
1338

  
1339
  my $wh_id  = $part->warehouse_id;
1340
  my $bin_id = $part->bin_id;
1341

  
1342
  if (!$wh_id && !$bin_id && $conf->get_transfer_default_ignore_onhand) {
1343
    $wh_id  = $conf->get_warehouse_id_ignore_onhand;
1344
    $bin_id = $conf->get_bin_id_ignore_onhand;
1345
  }
1346

  
1347
  $::lxdebug->leave_sub(2);
1348
  return ($wh_id, $bin_id);
1349
}
1350

  
1294 1351
sub _delete_payments {
1295 1352
  $main::lxdebug->enter_sub();
1296 1353

  
SL/WH.pm
110 110
          trans_id         => $trans_id,
111 111
          shippingdate     => !$transfer->{shippingdate} || $transfer->{shippingdate} eq 'current_date'
112 112
                              ? $now : $transfer->{shippingdate},
113
          map { $_ => $transfer->{$_} } qw( chargenumber bestbefore oe_id delivery_order_items_stock_id comment),
113
          map { $_ => $transfer->{$_} } qw(chargenumber bestbefore oe_id delivery_order_items_stock_id invoice_id comment),
114 114
      );
115 115

  
116 116
      if ($unit) {
bin/mozilla/is.pl
39 39
use DateTime;
40 40
use List::MoreUtils qw(uniq);
41 41
use List::Util qw(max sum);
42
use English qw(-no_match_vars);
42 43

  
43 44
use SL::DB::Default;
44 45
use SL::DB::Customer;
......
778 779
  }
779 780

  
780 781
  relink_accounts();
781
  $form->error($locale->text('Cannot post invoice!'))
782
    unless IS->post_invoice(\%myconfig, \%$form);
782

  
783
  # If transfer_out is requested, get rose db handle and do post and
784
  # transfer out in one transaction. Otherwise just post the invoice.
785
  if ($::instance_conf->get_is_transfer_out) {
786
    require SL::DB::Inventory;
787
    my $rose_db = SL::DB::Inventory->new->db;
788
    my $error;
789

  
790
    if (!$rose_db->with_transaction(sub {
791
      if (!eval {
792
        IS->post_invoice(\%myconfig, \%$form, $rose_db->dbh);
793
        IS->transfer_out(\%$form);
794
        1;
795
      }) {
796
        $error = $EVAL_ERROR;
797
        return;
798
      }
799

  
800
      1;
801
    })) {
802
      $form->error($locale->text("Cannot post invoice and/or transfer out!\nError was:\n") . $locale->text($error));
803
    }
804
  } else {
805
    if (!IS->post_invoice(\%myconfig, \%$form)) {
806
      $form->error($locale->text('Cannot post invoice!'));
807
    }
808
  }
809

  
783 810
  remove_draft() if $form->{remove_draft};
784 811

  
785 812
  if(!exists $form->{addition}) {

Auch abrufbar als: Unified diff