use parent qw(SL::Controller::Base);
use SL::Helper::Flash qw(flash_later);
-use SL::Helper::Number qw(_format_number_units _parse_number);
+use SL::Helper::Number qw(_format_number _parse_number);
use SL::Presenter::Tag qw(select_tag hidden_tag div_tag);
use SL::Presenter::DeliveryOrder qw(delivery_order_status_line);
use SL::Locale::String qw(t8);
$::form->{id} = $self->order->id; # this is used in SL::Mailer to create a linked record to the mail
$::form->send_email(\%::myconfig, 'pdf');
- # internal notes
- my $intnotes = $self->order->intnotes;
- $intnotes .= "\n\n" if $self->order->intnotes;
- $intnotes .= t8('[email]') . "\n";
- $intnotes .= t8('Date') . ": " . $::locale->format_date_object(DateTime->now_local, precision => 'seconds') . "\n";
- $intnotes .= t8('To (email)') . ": " . $::form->{email} . "\n";
- $intnotes .= t8('Cc') . ": " . $::form->{cc} . "\n" if $::form->{cc};
- $intnotes .= t8('Bcc') . ": " . $::form->{bcc} . "\n" if $::form->{bcc};
- $intnotes .= t8('Subject') . ": " . $::form->{subject} . "\n\n";
- $intnotes .= t8('Message') . ": " . $::form->{message};
+ # internal notes unless no email journal
+ unless ($::instance_conf->get_email_journal) {
- $self->order->update_attributes(intnotes => $intnotes);
+ my $intnotes = $self->order->intnotes;
+ $intnotes .= "\n\n" if $self->order->intnotes;
+ $intnotes .= t8('[email]') . "\n";
+ $intnotes .= t8('Date') . ": " . $::locale->format_date_object(DateTime->now_local, precision => 'seconds') . "\n";
+ $intnotes .= t8('To (email)') . ": " . $::form->{email} . "\n";
+ $intnotes .= t8('Cc') . ": " . $::form->{cc} . "\n" if $::form->{cc};
+ $intnotes .= t8('Bcc') . ": " . $::form->{bcc} . "\n" if $::form->{bcc};
+ $intnotes .= t8('Subject') . ": " . $::form->{subject} . "\n\n";
+ $intnotes .= t8('Message') . ": " . $::form->{message};
+
+ $self->order->update_attributes(intnotes => $intnotes);
+ }
$self->save_history('MAILED');
my ($self) = @_;
my $part = SL::DB::Part->load_cached($::form->{parts_id}) or die "need parts_id";
+ my $unit = SL::DB::Unit->load_cached($::form->{unit}) or die "need unit";
my $stock = $::form->{stock};
- my $unit = $::form->{unit};
my $row = $::form->{row};
my $item_id = $::form->{item_id};
my $qty = _parse_number($::form->{qty_as_number});
my @contents = DO->get_item_availability(parts_id => $part->id);
my $stock_info = DO->unpack_stock_information(packed => $stock);
- $self->merge_stock_data($stock_info, \@contents, $part);
+ $self->merge_stock_data($stock_info, \@contents, $part, $unit);
$self->render("delivery_order/stock_dialog", { layout => 0 },
WHCONTENTS => $self->order->delivered ? $stock_info : \@contents,
part => $part,
do_qty => $qty,
- do_unit => $unit,
+ do_unit => $unit->unit,
delivered => $self->order->delivered,
row => $row,
item_id => $item_id,
stock_info => $yaml,
stock_qty => $stock_qty,
};
-
$self->render(\ SL::JSON::to_json($response), { layout => 0, type => 'json', process => 0 });
}
sub merge_stock_data {
- my ($self, $stock_info, $contents, $part) = @_;
+ my ($self, $stock_info, $contents, $part, $unit) = @_;
# TODO rewrite to mapping
if (!$self->order->delivered) {
for my $row (@$contents) {
- $row->{available_qty} = _format_number_units($row->{qty}, $row->{unit}, $part->unit);
+ # row here is in parts units. stock is in item units
+ $row->{available_qty} = _format_number($part->unit_obj->convert_to($row->{qty}, $unit));
for my $sinfo (@{ $stock_info }) {
next if $row->{bin_id} != $sinfo->{bin_id} ||
action => [
t8('Save as new'),
call => [ 'kivi.DeliveryOrder.save', 'save_as_new', $::instance_conf->get_order_warn_duplicate_parts ],
- disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef,
+ disabled => $self->type eq 'supplier_delivery_order' ? t8('Need a workflow for Supplier Delivery Order')
+ : !$self->order->id ? t8('This object has not been saved yet.')
+ : undef,
],
], # end of combobox "Save"
$units_by_name{$_->{unit}}->convert_to($_->{qty}, $units_by_name{$unit})
} @$stock_info;
- my $content = _format_number_units($sum, 2, $units_by_name{$unit}, $units_by_name{$unit});
+ my $content = _format_number($sum, 2) . ' ' . $unit;
return $content;
}
$_->unit_obj->convert_to($_->qty, $item->unit_obj)
} $item->delivery_order_stock_entries;
- my $content = _format_number_units($sum, 2, $item->unit_obj, $item->part->unit_obj);
+ my $content = _format_number($sum, 2);
return $content;
}