__PACKAGE__->run_before('check_auth');
use Rose::Object::MakeMethods::Generic (
- 'scalar --get_set_init' => [ qw(defaults all_warehouses all_weightunits all_languages all_currencies all_templates all_parts posting_options payment_options accounting_options inventory_options profit_options accounts balance_startdate_method_options) ],
+ 'scalar --get_set_init' => [ qw(defaults all_warehouses all_weightunits all_languages all_currencies all_templates all_parts_time_unit
+ posting_options payment_options accounting_options inventory_options profit_options accounts balance_startdate_method_options) ],
);
sub action_edit {
sub init_all_warehouses { SL::DB::Manager::Warehouse->get_all_sorted }
sub init_all_languages { SL::DB::Manager::Language->get_all_sorted }
sub init_all_currencies { SL::DB::Manager::Currency->get_all_sorted }
-sub init_all_parts { SL::DB::Manager::Part->get_all_sorted }
sub init_all_weightunits { my $unit = SL::DB::Manager::Unit->find_by(name => 'kg'); $unit ? $unit->convertible_units : [] }
sub init_all_templates { +{ SL::Template->available_templates } }
+sub init_all_parts_time_unit {
+ my $h_unit = first { $_ } map { SL::DB::Manager::Unit->find_by(name => $_) } qw(Std h Stunde);
+ return [] unless $h_unit;
+
+ my @convertible_unit_names = map { $_->name } @{ $h_unit->convertible_units };
+
+ return SL::DB::Manager::Part->get_all_sorted(where => [ unit => \@convertible_unit_names ]);
+}
+
sub init_posting_options {
[ { title => t8("never"), value => 0 },
{ title => t8("every time"), value => 1 },
use Rose::Object::MakeMethods::Generic
(
scalar => [ qw(parts) ],
- 'scalar --get_set_init' => [ qw(requirement_spec rs_order js h_unit_name all_customers all_parts) ],
+ 'scalar --get_set_init' => [ qw(requirement_spec rs_order js h_unit_name all_customers all_parts_time_unit) ],
);
__PACKAGE__->run_before('setup');
sub action_new {
my ($self) = @_;
+ if (!@{ $self->all_parts_time_unit }) {
+ return $self->js->flash('error', t8('This function requires the presence of articles with a time-based unit such as "h" or "min".'))->render($self);
+ }
+
my $html = $self->render('requirement_spec_order/new', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description });
$self->js->html('#' . TAB_ID(), $html)
->render($self);
sub action_edit_assignment {
my ($self) = @_;
+ if (!@{ $self->all_parts_time_unit }) {
+ return $self->js->flash('error', t8('This function requires the presence of articles with a time-based unit such as "h" or "min".'))->render($self);
+ }
+
my $html = $self->render('requirement_spec_order/edit_assignment', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description });
$self->js->html('#' . TAB_ID(), $html)
->render($self);
}
sub init_all_customers { SL::DB::Manager::Customer->get_all_sorted }
-sub init_all_parts { SL::DB::Manager::Part->get_all_sorted }
sub init_h_unit_name { first { SL::DB::Manager::Unit->find_by(name => $_) } qw(Std h Stunde) };
sub init_rs_order { SL::DB::RequirementSpecOrder->new(id => $::form->{rs_order_id})->load };
+sub init_all_parts_time_unit {
+ my ($self) = @_;
+
+ return [] unless $self->h_unit_name;
+
+ my @convertible_unit_names = map { $_->name } @{ SL::DB::Manager::Unit->find_by(name => $self->h_unit_name)->convertible_units };
+
+ return SL::DB::Manager::Part->get_all_sorted(where => [ unit => \@convertible_unit_names ]);
+}
+
#
# helpers
#
'This could have happened for two reasons:' => 'Dies kann aus zwei Gründen geschehen sein:',
'This customer number is already in use.' => 'Diese Kundennummer wird bereits verwendet.',
'This feature especially prevents mistakes by mixing up prior tax and sales tax.' => 'Dieses Feature vermeidet insbesondere Verwechslungen von Umsatz- und Vorsteuer.',
+ 'This function requires the presence of articles with a time-based unit such as "h" or "min".' => 'Für diese Funktion mussen Artikel mit einer Zeit-basierten Einheit wie "Std" oder "min" existieren.',
'This group is valid for the following clients' => 'Diese Gruppe ist für die folgenden Mandanten gültig',
'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => 'Das wurde in dieser Version umgestellt, bitte ändern Sie die Freitext-Lagerplätze auf vorhandene Lagerplätze.',
'This has been changed in this version.' => 'Ab dieser Version ist dies nicht mehr so.',
<tr>
<td align="right">[% LxERP.t8('Default article for converting into quotations and orders') %]</td>
- <td>[% L.select_tag('defaults.requirement_spec_section_order_part_id', SELF.all_parts, default=SELF.defaults.requirement_spec_section_order_part_id, with_empty=1, title_sub=\make_part_title) %]</td>
+ <td>[% L.select_tag('defaults.requirement_spec_section_order_part_id', SELF.all_parts_time_unit, default=SELF.defaults.requirement_spec_section_order_part_id, with_empty=1, title_sub=\make_part_title) %]</td>
<td>[% LxERP.t8('When converting a requirement spec into a quotation or an oder each section gets converted into a line position in the new record. This is the article used by default for this conversion.') %]</td>
</tr>
</table>
<tr>
<td>[% LxERP.t8("Assign the following article to all sections") %]:</td>
<td>
- [% L.select_tag('quotations_and_orders_dummy', SELF.all_parts, default=INSTANCE_CONF.get_requirement_spec_section_order_part_id, title_sub=\make_part_title, id='quoations_and_orders_order_id', style=style) %]
+ [% L.select_tag('quotations_and_orders_dummy', SELF.all_parts_time_unit, default=INSTANCE_CONF.get_requirement_spec_section_order_part_id, title_sub=\make_part_title, id='quoations_and_orders_order_id', style=style) %]
[% L.button_tag('kivi.requirement_spec.assign_order_part_id_to_all()', LxERP.t8('Assign article')) %]
</td>
</tr>
<td>[% HTML.escape(section.fb_number) %]</td>
<td>[% HTML.escape(section.title) %]</td>
<td>[% HTML.escape(P.truncate(section.description)) %]</td>
- <td>[% L.select_tag('sections[].order_part_id', SELF.all_parts, default=section.order_part_id, with_empty=!for_new, title_sub=\make_part_title, style=style, no_id=1) %]</td>
+ <td>[% L.select_tag('sections[].order_part_id', SELF.all_parts_time_unit, default=section.order_part_id, with_empty=!for_new, title_sub=\make_part_title, style=style, no_id=1) %]</td>
</tr>
[% END %]
</tbody>