@old_ids_cond,
]);
- $TMPL_VAR{ALL_PROJECTS} = SL::DB::Manager::Project->get_all(query => \@conditions);
+ $TMPL_VAR{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => \@conditions);
# label subs
my $employee_list_query_gen = sub { $::form->{$_[0]} ? [ or => [ id => $::form->{$_[0]}, deleted => 0 ] ] : [ deleted => 0 ] };
}
}
- $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase show_form_details show_history show_vc_details ckeditor/ckeditor ckeditor/adapters/jquery));
+ $::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase show_form_details show_history show_vc_details ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_customer));
$form->header;
if ($form->{CFDD_shipto} && $form->{CFDD_shipto_id} ) {
$TMPL_VAR{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
- my $tpca_reminder = check_transport_cost_reminder_article_number() if $::instance_conf->get_transport_cost_reminder_article_number;
+ my $tpca_reminder;
+ $tpca_reminder = check_transport_cost_reminder_article_number() if $::instance_conf->get_transport_cost_reminder_article_number_id;
print $form->parse_html_template("oe/form_footer", {
%TMPL_VAR,
webdav => $::instance_conf->get_webdav,
if ($sellprice) {
$form->{"sellprice_$i"} = $sellprice;
} else {
- $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
+ 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
}
$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);
-
- # get pricegroups for parts
- IS->get_pricegroups_for_parts(\%myconfig, \%$form);
-
- # build up html code for prices_$i
- &set_pricegroup($i);
}
display_form();
push @options, $locale->text('Customer') . " : $form->{customer}" if $form->{customer};
push @options, $locale->text('Vendor') . " : $form->{vendor}" if $form->{vendor};
+ push @options, $locale->text('Contact Person') . " : $form->{cp_name}" if $form->{cp_name};
push @options, $locale->text('Department') . " : $department" if $form->{department};
push @options, $locale->text('Order Number') . " : $form->{ordnumber}" if $form->{ordnumber};
push @options, $locale->text('Customer Order Number') . " : $form->{cusordnumber}" if $form->{cusordnumber};
if (OE->delete(\%myconfig, \%$form)){
# saving the history
if(!exists $form->{addition}) {
- $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
- $form->{addition} = "DELETED";
- $form->save_history;
+ 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);
# bo creates the id, reset it
map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued);
+ delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
$form->{ $form->{vc} } =~ s/--.*//g;
$form->{type} = "invoice";
$form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
}
- # show pricegroup in newly loaded invoice when creating invoice from quotation/order
- IS->get_pricegroups_for_parts(\%myconfig, \%$form);
- set_pricegroup($_) for 1 .. $form->{rowcount};
-
&display_form;
$main::lxdebug->leave_sub();
$form->{saveasnew} = 1;
map { delete $form->{$_} } qw(printed emailed queued delivered closed);
+ 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.
# reset
map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber);
+ delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"}; # always reset orderitems_id
# if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i
# also reset discounts
# reset
delete @{$form}{qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal closed delivered)};
+ delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
for my $i (1 .. $form->{rowcount}) {
map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice lastcost basefactor discount);
check_oe_access();
- my $transport_article = $::instance_conf->get_transport_cost_reminder_article_number;
+ my $transport_article_id = $::instance_conf->get_transport_cost_reminder_article_number_id;
for my $i (1 .. $form->{rowcount}) {
- return undef if $form->{"partnumber_${i}"} eq $transport_article;
+ return if $form->{"id_${i}"} eq $transport_article_id;
}
- return $transport_article;
+ # simply return the name of the part
+ return SL::DB::Part->new(id => $transport_article_id)->load()->partnumber;
$main::lxdebug->leave_sub();
}
sub dispatcher {
- foreach my $action (qw(delete delivery_order e_mail invoice print purchase_order purchase_order quotation
- request_for_quotation sales_order sales_order save save_and_close save_as_new ship_to update)) {
+ foreach my $action (qw(delete delivery_order e_mail 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.'));
}
+