# Delivery orders
#======================================================================
+use Carp;
use List::MoreUtils qw(uniq);
use List::Util qw(max sum);
use POSIX qw(strftime);
use SL::DO;
use SL::IR;
use SL::IS;
-use SL::MoreCommon qw(ary_diff);
+use SL::MoreCommon qw(ary_diff restore_form save_form);
use SL::ReportGenerator;
use SL::WH;
use Sort::Naturally ();
require "bin/mozilla/arap.pl";
require "bin/mozilla/common.pl";
-require "bin/mozilla/invoice_io.pl";
require "bin/mozilla/io.pl";
require "bin/mozilla/reportgenerator.pl";
set_headings("add");
+ $form->{show_details} = $::myconfig{show_form_details};
$form->{callback} = build_std_url('action=add', 'type', 'vc') unless ($form->{callback});
order_links();
my $form = $main::form;
+ $form->{show_details} = $::myconfig{show_form_details};
+
# show history button
$form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
#/show hhistory button
$form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
# retrieve order/quotation
- $form->{webdav} = $::instance_conf->get_webdav;
-
my $editing = $form->{id};
DO->retrieve('vc' => $form->{vc},
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer autocomplete_part));
+ my @custom_hidden;
+ push @custom_hidden, map { "shiptocvar_" . $_->name } @{ SL::DB::Manager::CustomVariableConfig->get_all(where => [ module => 'ShipTo' ]) };
+
+ $::form->{HIDDENS} = [ map { +{ name => $_, value => $::form->{$_} } } (@custom_hidden) ];
+
$form->header();
# Fix für Bug 1082 Erwartet wird: 'abteilungsNAME--abteilungsID'
# und Erweiterung für Bug 1760:
IS->get_customer(\%myconfig, \%$form);
$vc_discount = $form->{customer_discount};
}
- restore_form($saved_form);
+ # use payment terms from customer or vendor
+ restore_form($saved_form,0,qw(payment_id));
$form->{rowcount} = 0;
foreach my $ref (@{ $form->{form_details} }) {
$main::lxdebug->leave_sub();
}
+sub display_form {
+ $::lxdebug->enter_sub;
+
+ $::auth->assert('purchase_delivery_order_edit | sales_delivery_order_edit');
+
+ relink_accounts();
+ retrieve_partunits();
+
+ my $new_rowcount = $::form->{"rowcount"} * 1 + 1;
+ $::form->{"project_id_${new_rowcount}"} = $::form->{"globalproject_id"};
+
+ $::form->language_payment(\%::myconfig);
+
+ Common::webdav_folder($::form);
+
+ form_header();
+ display_row(++$::form->{rowcount});
+ form_footer();
+
+ $::lxdebug->leave_sub;
+}
sub yes {
call_sub($main::form->{yes_nextsub});
# dieser array_ref ist für DO->save da:
# einmal die all_requests in YAML verwandeln, damit delivery_order_items_stock
# gefüllt werden kann.
+ # could be dumped to the form in the first loop,
+ # but maybe bin_id and warehouse_id has changed to the "korrekturlager" with
+ # allowed negative qty ($::instance_conf->get_warehouse_id_ignore_onhand) ...
my $i = 0;
foreach (@all_requests){
$i++;
save(no_redirect => 1); # Wir können auslagern, deshalb beleg speichern
# und in delivery_order_items_stock speichern
+
+ # ... and fill back the persistent dois_id for inventory fk
+ undef (@all_requests);
+ foreach my $i (1 .. $form->{rowcount}) {
+ next unless ($form->{"id_$i"} && $form->{"stock_${prefix}_$i"});
+ push @all_requests, @{ DO->unpack_stock_information('packed' => $form->{"stock_${prefix}_$i"}) };
+ }
DO->transfer_in_out('direction' => $prefix,
'requests' => \@all_requests);