Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f92d73ce

Von Niklas Schmidt vor 10 Tagen hinzugefügt

  • ID f92d73cefd86a170fbf88f3fbe65795009cb137f
  • Vorgänger dbeba4e7
  • Nachfolger 36c672e1

bin/mozilla/oe.pl: entferne toten Code (Schritt 1)

nicht mehr benötigt:

-sub add {
-sub save_and_close {
-sub save {
-sub delete {
-sub save_as_new {
-sub purchase_order {
-sub sales_order {
-sub poso {
-sub oe_delivery_order_from_order {
-sub update {
-sub check_for_direct_delivery_yes {
-sub check_for_direct_delivery_no {
-sub check_for_direct_delivery {
-sub edit_periodic_invoices_config {
-sub save_periodic_invoices_config {
-sub dispatcher {

-sub check_delivered_flag {
-sub delivery_order {
-sub yes {
-sub no {

-sub edit {

benötigt für Workflow VK-Rechnung->Kundenauftrag:

sub order_links {

benötigt für Workflow VK-Auftragsbestätigung->Aktionen->in Lieferscheine umwandeln:

sub convert_to_delivery_orders {

benötigt für Auftrag->Rechnung:

sub invoice {
sub oe_prepare_xyz_from_order {
sub oe_invoice_from_order {
sub _remove_full_delivered_rows {
sub _oe_remove_delivered_or_billed_rows {

Unterschiede anzeigen:

bin/mozilla/oe.pl
$main::lxdebug->leave_sub();
}
sub add {
$main::lxdebug->enter_sub();
my $form = $main::form;
check_oe_access();
set_headings("add");
$form->{callback} =
"$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}"
unless $form->{callback};
$form->{show_details} = $::myconfig{show_form_details};
order_links(is_new => 1);
&prepare_order;
&display_form;
$main::lxdebug->leave_sub();
}
sub edit {
$main::lxdebug->enter_sub();
my $form = $main::form;
check_oe_access();
$form->{show_details} = $::myconfig{show_form_details};
$form->{taxincluded_changed_by_user} = 1;
# show history button
$form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
#/show hhistory button
$form->{simple_save} = 0;
set_headings("edit");
# editing without stuff to edit? try adding it first
if ($form->{rowcount} && !$form->{print_and_save}) {
my $c = SL::Controller::Order->new;
$c->action_edit_collective();
$main::lxdebug->leave_sub();
$::dispatcher->end_request;
my $id;
map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount});
if (!$id) {
# reset rowcount
undef $form->{rowcount};
&add;
$main::lxdebug->leave_sub();
return;
}
} elsif (!$form->{id}) {
&add;
$main::lxdebug->leave_sub();
return;
}
my ($language_id, $printer_id);
if ($form->{print_and_save}) {
$form->{action} = "dispatcher";
$form->{action_print} = "1";
$form->{resubmit} = 1;
$language_id = $form->{language_id};
$printer_id = $form->{printer_id};
}
set_headings("edit");
&order_links;
$form->{rowcount} = 0;
foreach my $ref (@{ $form->{form_details} }) {
$form->{rowcount}++;
map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{$ref};
}
&prepare_order;
if ($form->{print_and_save}) {
$form->{language_id} = $language_id;
$form->{printer_id} = $printer_id;
}
&display_form;
$main::lxdebug->leave_sub();
}
sub convert_to_delivery_orders {
# collect order ids
my @multi_ids = map {
......
$main::lxdebug->leave_sub();
}
sub update {
$main::lxdebug->enter_sub();
my ($recursive_call) = @_;
my $form = $main::form;
my %myconfig = %main::myconfig;
check_oe_access();
set_headings($form->{"id"} ? "edit" : "add");
$form->{update} = 1;
my $vc = $form->{vc};
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
if ($vc eq 'customer') {
IS->get_customer(\%myconfig, $form);
$::form->{billing_address_id} = $::form->{default_billing_address_id};
} else {
IR->get_vendor(\%myconfig, $form);
}
}
if (!$form->{forex}) { # read exchangerate from input field (not hidden)
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate) unless $recursive_call;
}
my $buysell = 'buy';
$buysell = 'sell' if ($form->{vc} eq 'vendor');
$form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell);
$form->{exchangerate} = $form->{forex} if $form->{forex};
my $exchangerate = $form->{exchangerate} || 1;
##################### process items ######################################
# for pricegroups
my $i = $form->{rowcount};
if ( ($form->{"partnumber_$i"} eq "")
&& ($form->{"description_$i"} eq "")
&& ($form->{"partsgroup_$i"} eq "")) {
$form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
&check_form;
} else {
my $mode;
if ($form->{type} =~ /^sales/) {
IS->retrieve_item(\%myconfig, \%$form);
$mode = 'IS';
} else {
IR->retrieve_item(\%myconfig, \%$form);
$mode = 'IR';
}
my $rows = scalar @{ $form->{item_list} };
$form->{"discount_$i"} = $form->parse_amount(\%myconfig, $form->{"discount_$i"}) / 100.0;
$form->{"discount_$i"} ||= $form->{"$form->{vc}_discount"};
$form->{"lastcost_$i"} = $form->parse_amount(\%myconfig, $form->{"lastcost_$i"});
if ($rows) {
$form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
if( !$form->{"qty_$i"} ) {
$form->{"qty_$i"} = 1;
}
if ($rows > 1) {
select_item(mode => $mode, pre_entered_qty => $form->{"qty_$i"});
$::dispatcher->end_request;
} else {
my $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
# hier werden parts (Artikeleigenschaften) aus item_list (retrieve_item aus IS.pm)
# (item wahrscheinlich synonym für parts) entsprechend in die form geschrieben ...
# Wäre dieses Mapping nicht besser in retrieve_items aufgehoben?
#(Eine Funktion bekommt Daten -> ARBEIT -> Rückgabe DATEN)
# Das quot sieht doch auch nach Überarbeitung aus ... (hmm retrieve_items gibt es in IS und IR)
map { $form->{item_list}[$i]{$_} =~ s/\"/&quot;/g } qw(partnumber description unit);
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
# ... deswegen muss die prüfung, ob es sich um einen nicht rabattierfähigen artikel handelt später erfolgen (Bug 1136)
$form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"};
$form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne "";
$form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
my $dec_qty = length $1;
my $decimalplaces = max 2, $dec_qty;
if ($sellprice) {
$form->{"sellprice_$i"} = $sellprice;
} else {
my $record = _make_record();
my $price_source = SL::PriceSource->new(record_item => $record->items->[$i-1], record => $record);
my $best_price = $price_source->best_price;
my $best_discount = $price_source->best_discount;
if ($best_price) {
$::form->{"sellprice_$i"} = $best_price->price;
$::form->{"active_price_source_$i"} = $best_price->source;
}
if ($best_discount) {
$::form->{"discount_$i"} = $best_discount->discount;
$::form->{"active_discount_source_$i"} = $best_discount->source;
}
$form->{"sellprice_$i"} /= $exchangerate; # if there is an exchange rate adjust sellprice
}
my $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"});
map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"};
map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{taxaccounts} if !$form->{taxincluded};
$form->{creditremaining} -= $amount;
$form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
$form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces);
$form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
$form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100.0);
}
display_form();
} else {
# ok, so this is a new part
# ask if it is a part or service item
if ( $form->{"partsgroup_$i"}
&& ($form->{"partsnumber_$i"} eq "")
&& ($form->{"description_$i"} eq "")) {
$form->{rowcount}--;
$form->{"discount_$i"} = "";
display_form();
} else {
$form->{"id_$i"} = 0;
new_item();
}
}
}
##################### process items ######################################
$main::lxdebug->leave_sub();
}
sub search {
$main::lxdebug->enter_sub();
......
$main::lxdebug->leave_sub();
}
sub check_delivered_flag {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
check_oe_access();
if (($form->{type} ne 'sales_order') && ($form->{type} ne 'purchase_order')) {
return $main::lxdebug->leave_sub();
}
my $all_delivered = 0;
foreach my $i (1 .. $form->{rowcount}) {
next if (!$form->{"id_$i"});
$form->{"ship_$i"} = 0 if $form->{saveasnew};
if ($form->parse_amount(\%myconfig, $form->{"qty_$i"}) == $form->parse_amount(\%myconfig, $form->{"ship_$i"})) {
$all_delivered = 1;
next;
}
$all_delivered = 0;
last;
}
$form->{delivered} = 1 if $all_delivered;
$form->{delivered} = 0 if $form->{saveasnew};
$main::lxdebug->leave_sub();
}
sub save_and_close {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
check_oe_access();
$form->mtime_ischanged('oe');
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
if ($form->{type} =~ /_order$/) {
$form->isblank("transdate", $locale->text('Order Date missing!'));
} else {
$form->isblank("transdate", $locale->text('Quotation Date missing!'));
}
my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
$form->{$idx} =~ s/^\s*//g;
$form->{$idx} =~ s/\s*$//g;
my $msg = ucfirst $form->{vc};
$form->isblank($form->{vc} . '_id', $locale->text($msg . " missing!"));
# $locale->text('Customer missing!');
# $locale->text('Vendor missing!');
$form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
if ($form->{currency} ne $form->{defaultcurrency});
&validate_items;
my $vc = $form->{vc};
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
IS->get_customer(\%myconfig, $form) if $vc eq 'customer';
IR->get_vendor(\%myconfig, $form) if $vc eq 'vendor';
$::form->{billing_address_id} = $::form->{default_billing_address_id};
update();
$::dispatcher->end_request;
}
$form->{id} = 0 if $form->{saveasnew};
my ($numberfld, $ordnumber, $err);
# this is for the internal notes section for the [email] Subject
if ($form->{type} =~ /_order$/) {
if ($form->{type} eq 'sales_order') {
$form->{label} = $locale->text('Sales Order');
$numberfld = "sonumber";
$ordnumber = "ordnumber";
} else {
$form->{label} = $locale->text('Purchase Order');
$numberfld = "ponumber";
$ordnumber = "ordnumber";
}
$err = $locale->text('Cannot save order!');
check_delivered_flag();
} else {
if ($form->{type} eq 'sales_quotation') {
$form->{label} = $locale->text('Quotation');
$numberfld = "sqnumber";
$ordnumber = "quonumber";
} else {
$form->{label} = $locale->text('Request for Quotation');
$numberfld = "rfqnumber";
$ordnumber = "quonumber";
}
$err = $locale->text('Cannot save quotation!');
}
# get new number in sequence if saveasnew was requested
delete $form->{$ordnumber} if $form->{saveasnew};
relink_accounts();
$form->error($err) if (!OE->save(\%myconfig, \%$form));
# saving the history
if(!exists $form->{addition}) {
$form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "SAVED";
$form->save_history;
}
# /saving the history
$form->redirect($form->{label} . " $form->{$ordnumber} " .
$locale->text('saved!'));
$main::lxdebug->leave_sub();
}
sub save {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
check_oe_access();
$form->mtime_ischanged('oe');
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
if ($form->{type} =~ /_order$/) {
$form->isblank("transdate", $locale->text('Order Date missing!'));
} else {
$form->isblank("transdate", $locale->text('Quotation Date missing!'));
}
my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
$form->{$idx} =~ s/^\s*//g;
$form->{$idx} =~ s/\s*$//g;
my $msg = ucfirst $form->{vc};
$form->isblank($form->{vc} . '_id', $locale->text($msg . " missing!"));
# $locale->text('Customer missing!');
# $locale->text('Vendor missing!');
$form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
if ($form->{currency} ne $form->{defaultcurrency});
remove_emptied_rows();
&validate_items;
my $vc = $form->{vc};
if (($form->{"previous_${vc}_id"} || $form->{"${vc}_id"}) != $form->{"${vc}_id"}) {
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
if ($vc eq 'customer') {
IS->get_customer(\%myconfig, $form);
$::form->{billing_address_id} = $::form->{default_billing_address_id};
} else {
IR->get_vendor(\%myconfig, $form);
}
update();
$::dispatcher->end_request;
}
$form->{id} = 0 if $form->{saveasnew};
my ($numberfld, $ordnumber, $err);
# this is for the internal notes section for the [email] Subject
if ($form->{type} =~ /_order$/) {
if ($form->{type} eq 'sales_order') {
$form->{label} = $locale->text('Sales Order');
$numberfld = "sonumber";
$ordnumber = "ordnumber";
} else {
$form->{label} = $locale->text('Purchase Order');
$numberfld = "ponumber";
$ordnumber = "ordnumber";
}
$err = $locale->text('Cannot save order!');
check_delivered_flag();
} else {
if ($form->{type} eq 'sales_quotation') {
$form->{label} = $locale->text('Quotation');
$numberfld = "sqnumber";
$ordnumber = "quonumber";
} else {
$form->{label} = $locale->text('Request for Quotation');
$numberfld = "rfqnumber";
$ordnumber = "quonumber";
}
$err = $locale->text('Cannot save quotation!');
}
relink_accounts();
OE->save(\%myconfig, \%$form);
# saving the history
if(!exists $form->{addition}) {
if ( $form->{formname} eq 'sales_quotation' or $form->{formname} eq 'request_quotation' ) {
$form->{snumbers} = qq|quonumber_| . $form->{quonumber};
} elsif ( $form->{formname} eq 'sales_order' or $form->{formname} eq 'purchase_order') {
$form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
};
$form->{what_done} = $form->{formname};
$form->{addition} = "SAVED";
$form->save_history;
}
# /saving the history
$form->{simple_save} = 1;
if(!$form->{print_and_save}) {
delete @{$form}{ary_diff([keys %{ $form }], [qw(login id script type cursor_fokus)])};
edit();
$::dispatcher->end_request;
}
$main::lxdebug->leave_sub();
}
sub delete {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
check_oe_access();
my ($msg, $err);
if ($form->{type} =~ /_order$/) {
$msg = $locale->text('Order deleted!');
$err = $locale->text('Cannot delete order!');
} else {
$msg = $locale->text('Quotation deleted!');
$err = $locale->text('Cannot delete quotation!');
}
if (OE->delete(\%myconfig, \%$form)){
# saving the history
if(!exists $form->{addition}) {
if ( $form->{formname} eq 'sales_quotation' or $form->{formname} eq 'request_quotation' ) {
$form->{snumbers} = qq|quonumber_| . $form->{quonumber};
} elsif ( $form->{formname} eq 'sales_order' or $form->{formname} eq 'purchase_order') {
$form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
};
$form->{what_done} = $form->{formname};
$form->{addition} = "DELETED";
$form->save_history;
}
# /saving the history
$form->info($msg);
$::dispatcher->end_request;
}
$form->error($err);
$main::lxdebug->leave_sub();
}
sub invoice {
$main::lxdebug->enter_sub();
......
$main::lxdebug->leave_sub();
}
sub save_as_new {
$main::lxdebug->enter_sub();
my $form = $main::form;
check_oe_access();
$form->{saveasnew} = 1;
map { delete $form->{$_} } qw(printed emailed queued delivered closed);
$form->{"converted_from_orderitems_id_$_"} = delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
# Let kivitendo assign a new order number if the user hasn't changed the
# previous one. If it has been changed manually then use it as-is.
my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
$form->{$idx} =~ s/^\s*//g;
$form->{$idx} =~ s/\s*$//g;
if ($form->{saved_xyznumber} &&
($form->{saved_xyznumber} eq $form->{$idx})) {
delete($form->{$idx});
}
# clear reqdate and transdate unless changed
if ( $form->{reqdate} && $form->{id} ) {
my $saved_order = OE->retrieve_simple(id => $form->{id});
if ( $saved_order && $saved_order->{reqdate} eq $form->{reqdate} && $saved_order->{transdate} eq $form->{transdate} ) {
my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval :
$form->{type} eq 'sales_order' ? $::instance_conf->get_delivery_date_interval : 1;
if ( ($form->{type} eq 'sales_order' && !$::instance_conf->get_deliverydate_on)
|| ($form->{type} eq 'sales_quotation' && !$::instance_conf->get_reqdate_on)) {
$form->{reqdate} = '';
} else {
$form->{reqdate} = DateTime->today_local->next_workday(extra_days => $extra_days)->to_kivitendo;
}
$form->{transdate} = DateTime->today_local->to_kivitendo;
}
}
# update employee
$form->get_employee();
&save;
$main::lxdebug->leave_sub();
}
sub check_for_direct_delivery_yes {
$main::lxdebug->enter_sub();
my $form = $main::form;
check_oe_access();
$form->{direct_delivery_checked} = 1;
delete @{$form}{grep /^shipto/, keys %{ $form }};
map { s/^CFDD_//; $form->{$_} = $form->{"CFDD_${_}"} } grep /^CFDD_/, keys %{ $form };
$form->{CFDD_shipto} = 1;
purchase_order();
$main::lxdebug->leave_sub();
}
sub check_for_direct_delivery_no {
$main::lxdebug->enter_sub();
my $form = $main::form;
check_oe_access();
$form->{direct_delivery_checked} = 1;
delete @{$form}{grep /^shipto/, keys %{ $form }};
$form->{CFDD_shipto} = 0;
purchase_order();
$main::lxdebug->leave_sub();
}
sub check_for_direct_delivery {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
check_oe_access();
if ($form->{direct_delivery_checked}
|| (!$form->{shiptoname} && !$form->{shiptostreet} && !$form->{shipto_id})) {
$main::lxdebug->leave_sub();
return;
}
my $cvars = SL::DB::Shipto->new->cvars_by_config;
if ($form->{shipto_id}) {
Common->get_shipto_by_id(\%myconfig, $form, $form->{shipto_id}, "CFDD_");
} else {
map { $form->{"CFDD_${_}"} = $form->{$_ } } grep /^shipto/, keys %{ $form };
}
$_->value($::form->{"CFDD_shiptocvar_" . $_->config->name}) for @{ $cvars };
delete $form->{action};
$form->{VARIABLES} = [ map { { "key" => $_, "value" => $form->{$_} } } grep { ($_ ne 'login') && ($_ ne 'password') && (ref $_ eq "") } keys %{ $form } ];
$form->header();
print $form->parse_html_template("oe/check_for_direct_delivery", { cvars => $cvars });
$main::lxdebug->leave_sub();
$::dispatcher->end_request;
}
sub purchase_order {
$main::lxdebug->enter_sub();
my $form = $main::form;
my $locale = $main::locale;
check_oe_access();
$form->mtime_ischanged('oe');
$main::auth->assert('purchase_order_edit');
$form->{sales_order_to_purchase_order} = 0;
if ($form->{type} eq 'sales_order') {
$form->{sales_order_to_purchase_order} = 1;
check_for_direct_delivery();
}
if ($form->{type} =~ /^sales_/) {
delete($form->{ordnumber});
delete($form->{payment_id});
delete($form->{delivery_term_id});
}
$form->{cp_id} *= 1;
my $source_type = $form->{type};
$form->{title} = $locale->text('Add Purchase Order');
$form->{vc} = "vendor";
$form->{type} = "purchase_order";
$form->get_employee();
poso(source_type => $form->{type});
delete $form->{sales_order_to_purchase_order};
$main::lxdebug->leave_sub();
}
sub sales_order {
$main::lxdebug->enter_sub();
my $form = $main::form;
my $locale = $main::locale;
check_oe_access();
$main::auth->assert('sales_order_edit');
$form->mtime_ischanged('oe');
if ($form->{type} eq "purchase_order") {
delete($form->{ordnumber});
$form->{"lastcost_$_"} = $form->{"sellprice_$_"} for (1..$form->{rowcount});
}
$form->{cp_id} *= 1;
my $source_type = $form->{type};
$form->{title} = $locale->text('Add Sales Order');
$form->{vc} = "customer";
$form->{type} = "sales_order";
$form->get_employee();
poso(source_type => $source_type);
$main::lxdebug->leave_sub();
}
sub poso {
$main::lxdebug->enter_sub();
my %param = @_;
my $form = $main::form;
my %myconfig = %main::myconfig;
check_oe_access();
$main::auth->assert('purchase_order_edit | sales_order_edit');
$form->{transdate} = $form->current_date(\%myconfig);
delete $form->{duedate};
# "reqdate" is the validity date for a quotation and the delivery
# date for an order. Therefore it makes no sense to keep the value
# when converting from one into the other.
delete $form->{reqdate} if ($param{source_type} =~ /_quotation$/) == ($form->{type} =~ /_quotation$/);
$form->{convert_from_oe_ids} = $form->{id};
$form->{closed} = 0;
$form->{old_employee_id} = $form->{employee_id};
$form->{old_salesman_id} = $form->{salesman_id};
# reset
map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber
taxzone_id currency);
# this converted variable is also used for sales_order to purchase order and vice versa
$form->{"converted_from_orderitems_id_$_"} = delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
# if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i
# also reset discounts
if ( $form->{sales_order_to_purchase_order} ) {
for my $i (1 .. $form->{rowcount}) {
$form->{"sellprice_${i}"} = $form->{"lastcost_${i}"};
$form->{"discount_${i}"} = 0;
};
};
for my $i (1 .. $form->{rowcount}) {
map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice basefactor discount lastcost);
}
my %saved_vars = map { $_ => $form->{$_} } grep { $form->{$_} } qw(currency);
&order_links;
map { $form->{$_} = $saved_vars{$_} } keys %saved_vars;
# prepare_order assumes that the discount is in db-notation (0.05) and not user-notation (5)
# and therefore multiplies the values by 100 in the case of reading from db or making an order
# from several quotation, so we convert this back into percent-notation for the user interface by multiplying with 0.01
# ergänzung 03.10.2010 muss vor prepare_order passieren (s.a. Svens Kommentar zu Bug 1017)
# das parse_amount wird oben schon ausgeführt, deswegen an dieser stelle raus (wichtig: kommawerte bei discount testen)
for my $i (1 .. $form->{rowcount}) {
$form->{"discount_$i"} /=100;
};
&prepare_order;
&update;
$main::lxdebug->leave_sub();
}
sub delivery_order {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
$form->mtime_ischanged('oe');
if ($form->{type} =~ /^sales/) {
$main::auth->assert('sales_delivery_order_edit');
$form->{vc} = 'customer';
$form->{type} = 'sales_delivery_order';
} else {
$main::auth->assert('purchase_delivery_order_edit');
$form->{vc} = 'vendor';
$form->{type} = 'purchase_delivery_order';
}
$form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_DELIVERY_ORDER_SAVE())->token;
$form->get_employee();
require "bin/mozilla/do.pl";
$form->{script} = 'do.pl';
$form->{cp_id} *= 1;
$form->{convert_from_oe_ids} = $form->{id};
$form->{transdate} = $form->current_date(\%myconfig);
delete $form->{duedate};
$form->{old_employee_id} = $form->{employee_id};
$form->{old_salesman_id} = $form->{salesman_id};
_oe_remove_delivered_or_billed_rows(id => $form->{id}, type => 'delivered');
# reset
delete @{$form}{qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal closed delivered)};
for my $i (1 .. $form->{rowcount}) {
map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice lastcost basefactor discount);
$form->{"converted_from_orderitems_id_$i"} = delete $form->{"orderitems_id_$i"};
}
my %old_values = map { $_ => $form->{$_} } qw(customer_id oldcustomer customer vendor_id oldvendor vendor shipto_id);
order_links();
prepare_order();
map { $form->{$_} = $old_values{$_} if ($old_values{$_}) } keys %old_values;
for my $i (1 .. $form->{rowcount}) {
(my $dummy, $form->{"pricegroup_id_$i"}) = split /--/, $form->{"sellprice_pg_$i"};
}
update();
$main::lxdebug->leave_sub();
}
sub oe_prepare_xyz_from_order {
return if !$::form->{id};
......
_update_ship();
}
sub oe_delivery_order_from_order {
oe_prepare_xyz_from_order();
delivery_order();
}
sub oe_invoice_from_order {
oe_prepare_xyz_from_order();
invoice();
}
sub yes {
call_sub($main::form->{yes_nextsub});
}
sub no {
call_sub($main::form->{no_nextsub});
}
######################################################################################################
# IO ENTKOPPLUNG
......
return $content;
}
sub edit_periodic_invoices_config {
$::lxdebug->enter_sub();
$::form->{type} = 'sales_order';
check_oe_access();
my $config;
$config = SL::YAML::Load($::form->{periodic_invoices_config}) if $::form->{periodic_invoices_config};
if ('HASH' ne ref $config) {
$config = { periodicity => 'm',
order_value_periodicity => 'p', # = same as periodicity
start_date_as_date => $::form->{transdate} || $::form->current_date,
extend_automatically_by => 12,
active => 1,
};
}
# for older configs, replace email preset text if not yet set.
$config->{email_subject} ||= GenericTranslations->get(language_id => $::form->{lanuage_id}, translation_type => "preset_text_periodic_invoices_email_subject");
$config->{email_body} ||= GenericTranslations->get(language_id => $::form->{lanuage_id}, translation_type => "salutation_general")
. GenericTranslations->get(language_id => $::form->{lanuage_id}, translation_type => "salutation_punctuation_mark")
. "\n\n"
. GenericTranslations->get(language_id => $::form->{lanuage_id}, translation_type => "preset_text_periodic_invoices_email_body");
$config->{email_body} =~ s{\A[ \n\r]+|[ \n\r]+\Z}{}g;
$config->{periodicity} = 'm' if none { $_ eq $config->{periodicity} } @SL::DB::PeriodicInvoicesConfig::PERIODICITIES;
$config->{order_value_periodicity} = 'p' if none { $_ eq $config->{order_value_periodicity} } ('p', @SL::DB::PeriodicInvoicesConfig::ORDER_VALUE_PERIODICITIES);
$::form->get_lists(printers => "ALL_PRINTERS",
charts => { key => 'ALL_CHARTS',
transdate => 'current_date' });
$::form->{AR} = [ grep { $_->{link} =~ m/(?:^|:)AR(?::|$)/ } @{ $::form->{ALL_CHARTS} } ];
$::form->{title} = $::locale->text('Edit the configuration for periodic invoices');
if ($::form->{customer_id}) {
$::form->{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(where => [ cp_cv_id => $::form->{customer_id} ]);
$::form->{email_recipient_invoice_address} = SL::DB::Manager::Customer->find_by(id => $::form->{customer_id})->invoice_mail;
}
$::form->header(no_layout => 1);
print $::form->parse_html_template('oe/edit_periodic_invoices_config', {config => $config});
$::lxdebug->leave_sub();
}
sub save_periodic_invoices_config {
$::lxdebug->enter_sub();
$::form->{type} = 'sales_order';
check_oe_access();
$::form->isblank('start_date_as_date', $::locale->text('The start date is missing.'));
my $config = { active => $::form->{active} ? 1 : 0,
terminated => $::form->{terminated} ? 1 : 0,
direct_debit => $::form->{direct_debit} ? 1 : 0,
periodicity => (any { $_ eq $::form->{periodicity} } @SL::DB::PeriodicInvoicesConfig::PERIODICITIES) ? $::form->{periodicity} : 'm',
order_value_periodicity => (any { $_ eq $::form->{order_value_periodicity} } ('p', @SL::DB::PeriodicInvoicesConfig::ORDER_VALUE_PERIODICITIES)) ? $::form->{order_value_periodicity} : 'p',
start_date_as_date => $::form->{start_date_as_date},
end_date_as_date => $::form->{end_date_as_date},
first_billing_date_as_date => $::form->{first_billing_date_as_date},
print => $::form->{print} ? 1 : 0,
printer_id => $::form->{print} ? $::form->{printer_id} * 1 : undef,
copies => $::form->{copies} * 1 ? $::form->{copies} : 1,
extend_automatically_by => $::form->{extend_automatically_by} * 1 || undef,
ar_chart_id => $::form->{ar_chart_id} * 1,
send_email => $::form->{send_email} ? 1 : 0,
email_recipient_contact_id => $::form->{email_recipient_contact_id} * 1 || undef,
email_recipient_address => $::form->{email_recipient_address},
email_sender => $::form->{email_sender},
email_subject => $::form->{email_subject},
email_body => $::form->{email_body},
};
$::form->{periodic_invoices_config} = SL::YAML::Dump($config);
$::form->{title} = $::locale->text('Edit the configuration for periodic invoices');
$::form->header;
print $::form->parse_html_template('oe/save_periodic_invoices_config', $config);
$::lxdebug->leave_sub();
}
sub _remove_full_delivered_rows {
my @fields = map { s/_1$//; $_ } grep { m/_1$/ } keys %{ $::form };
......
_remove_billed_or_delivered_rows(quantities => \%handled_base_qtys);
}
sub dispatcher {
foreach my $action (qw(delete delivery_order invoice print purchase_order quotation
request_for_quotation sales_order save save_and_close save_as_new ship_to update)) {
if ($::form->{"action_${action}"}) {
call_sub($action);
return;
}
}
$::form->error($::locale->text('No action defined.'));
}

Auch abrufbar als: Unified diff