12 |
12 |
|
13 |
13 |
use Rose::Object::MakeMethods::Generic (
|
14 |
14 |
scalar => [ qw(db_args flat_filter) ],
|
15 |
|
'scalar --get_set_init' => [ qw(models all_edit_right vc) ],
|
|
15 |
'scalar --get_set_init' => [ qw(models all_edit_right mode vc) ],
|
16 |
16 |
);
|
17 |
17 |
|
18 |
18 |
__PACKAGE__->run_before(sub { $::auth->assert('delivery_plan'); });
|
... | ... | |
22 |
22 |
description => t8('Description'),
|
23 |
23 |
partnumber => t8('Part Number'),
|
24 |
24 |
qty => t8('Qty'),
|
|
25 |
unit => t8('Unit'),
|
25 |
26 |
shipped_qty => t8('shipped'),
|
26 |
27 |
delivered_qty => t8('transferred in / out'),
|
27 |
28 |
not_shipped_qty => t8('not shipped'),
|
... | ... | |
48 |
49 |
my ($self) = @_;
|
49 |
50 |
|
50 |
51 |
my $vc = $self->vc;
|
|
52 |
my $mode = $self->mode;
|
51 |
53 |
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
|
|
54 |
my $csv_option = $::form->{report_generator_output_format};
|
52 |
55 |
$self->{report} = $report;
|
53 |
56 |
|
54 |
57 |
my @columns = qw(reqdate customer vendor ordnumber partnumber description qty shipped_qty not_shipped_qty delivered_qty value_of_goods);
|
55 |
58 |
|
56 |
59 |
my @sortable = qw(reqdate customer vendor ordnumber partnumber description);
|
|
60 |
my $rp_csv_mod = ($csv_option eq 'CSV' && $mode eq 'delivery_value_report') ? 1 : '';
|
57 |
61 |
|
58 |
62 |
my %column_defs = (
|
59 |
63 |
reqdate => { sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date } },
|
... | ... | |
61 |
65 |
obj_link => sub { $self->link_to($_[0]->part) } },
|
62 |
66 |
partnumber => { sub => sub { $_[0]->part->partnumber },
|
63 |
67 |
obj_link => sub { $self->link_to($_[0]->part) } },
|
64 |
|
qty => { sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit } },
|
65 |
|
shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
|
66 |
|
not_shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
|
67 |
|
delivered_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->delivered_qty, 2) . ' ' . $_[0]->unit } },
|
|
68 |
qty => { sub => sub { $_[0]->qty_as_number .
|
|
69 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } },
|
|
70 |
unit => { sub => sub { $_[0]->unit },
|
|
71 |
visible => $rp_csv_mod },
|
|
72 |
shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) .
|
|
73 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } },
|
|
74 |
not_shipped_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]->shipped_qty, 2) .
|
|
75 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } },
|
|
76 |
delivered_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->delivered_qty, 2) .
|
|
77 |
($rp_csv_mod ? '' : ' ' . $_[0]->unit) } },
|
68 |
78 |
ordnumber => { sub => sub { $_[0]->order->ordnumber },
|
69 |
79 |
obj_link => sub { $self->link_to($_[0]->order) } },
|
70 |
80 |
vendor => { sub => sub { $_[0]->order->vendor->name },
|
... | ... | |
74 |
84 |
visible => $vc eq 'customer',
|
75 |
85 |
obj_link => sub { $self->link_to($_[0]->order->customer) } },
|
76 |
86 |
value_of_goods => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->value_of_goods, 2) . ' ' . $_[0]->taxincluded },
|
77 |
|
visible => $::auth->assert('sales_order_edit', 1) && $::instance_conf->get_delivery_plan_show_value_of_goods, },
|
|
87 |
visible => $::auth->assert('sales_order_edit', 1) && $mode eq 'delivery_value_report' && $::instance_conf->get_delivery_plan_show_value_of_goods, },
|
78 |
88 |
);
|
79 |
89 |
|
80 |
90 |
$column_defs{$_}->{text} = $sort_columns{$_} for keys %column_defs;
|
... | ... | |
83 |
93 |
std_column_visibility => 1,
|
84 |
94 |
controller_class => 'DeliveryPlan',
|
85 |
95 |
output_format => 'HTML',
|
86 |
|
top_info_text => ($vc eq 'customer') ? $::locale->text('Delivery Plan for currently outstanding sales orders') :
|
|
96 |
top_info_text => ($vc eq 'customer') ? (($mode eq 'delivery_plan') ? $::locale->text('Delivery Plan for currently outstanding sales orders') :
|
|
97 |
$::locale->text('Delivery Value Report for currently open sales orders')) :
|
|
98 |
($mode eq 'delivery_value_report') ? $::locale->text('Delivery Value Report for currently outstanding purchase orders') :
|
87 |
99 |
$::locale->text('Delivery Plan for currently outstanding purchase orders'),
|
88 |
|
title => $::locale->text('Delivery Plan'),
|
|
100 |
title => ($mode eq 'delivery_plan') ? $::locale->text('Delivery Plan') : $::locale->text('Delivery Value Report'),
|
89 |
101 |
allow_pdf_export => 1,
|
90 |
102 |
allow_csv_export => 1,
|
91 |
103 |
);
|
92 |
104 |
$report->set_columns(%column_defs);
|
93 |
105 |
$report->set_column_order(@columns);
|
94 |
|
$report->set_export_options(qw(list filter vc));
|
|
106 |
$report->set_export_options(qw(list filter vc mode));
|
95 |
107 |
$report->set_options_from_form;
|
96 |
108 |
$self->models->disable_plugin('paginated') if $report->{options}{output_format} =~ /^(pdf|csv)$/i;
|
97 |
109 |
$self->models->finalize; # for filter laundering
|
98 |
110 |
$self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
|
99 |
111 |
$report->set_options(
|
100 |
|
raw_top_info_text => $self->render('delivery_plan/report_top', { output => 0 }, vc => $vc),
|
|
112 |
raw_top_info_text => $self->render('delivery_plan/report_top', { output => 0 }),
|
101 |
113 |
raw_bottom_info_text => $self->render('delivery_plan/report_bottom', { output => 0 }, models => $self->models),
|
102 |
114 |
);
|
103 |
115 |
}
|
... | ... | |
105 |
117 |
sub make_filter_summary {
|
106 |
118 |
my ($self) = @_;
|
107 |
119 |
my $vc = $self->vc;
|
|
120 |
my $mode = $self->mode;
|
108 |
121 |
|
109 |
122 |
my $filter = $::form->{filter} || {};
|
110 |
123 |
my @filter_strings;
|
... | ... | |
142 |
155 |
sub delivery_plan_query {
|
143 |
156 |
my ($self) = @_;
|
144 |
157 |
my $vc = $self->vc;
|
|
158 |
my $mode = $self->mode;
|
145 |
159 |
my $employee_id = SL::DB::Manager::Employee->current->id;
|
146 |
160 |
my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND";
|
147 |
161 |
# check delivered state for delivery_orders (transferred out) if enabled
|
148 |
|
my $filter_delivered = $::instance_conf->get_delivery_plan_calculate_transferred_do ?
|
149 |
|
"AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : '';
|
|
162 |
# OR if we are delivery_value_report mode
|
|
163 |
my $filter_delivered = ($::instance_conf->get_delivery_plan_calculate_transferred_do ||
|
|
164 |
$mode eq 'delivery_value_report' ) ?
|
|
165 |
"AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : '';
|
|
166 |
# Show ALL open orders in delivery_value_report mode
|
|
167 |
my $comment_show_all_open_orders = ($mode eq 'delivery_value_report' ) ? "-- " : "";
|
150 |
168 |
[
|
151 |
169 |
"order.${vc}_id" => { gt => 0 },
|
152 |
170 |
'order.closed' => 0,
|
... | ... | |
239 |
257 |
FROM record_links rl
|
240 |
258 |
WHERE oi.trans_id = rl.from_id AND rl.from_table = 'oe' AND rl.to_table = 'delivery_orders'
|
241 |
259 |
) AND
|
242 |
|
coalesce(sum, 0) < oi.qty AND
|
|
260 |
$comment_show_all_open_orders coalesce(sum, 0) < oi.qty AND
|
243 |
261 |
oe.${vc}_id IS NOT NULL AND
|
244 |
262 |
$oe_owner
|
245 |
263 |
(oe.quotation = 'f' OR oe.quotation IS NULL) AND NOT oe.closed
|
... | ... | |
250 |
268 |
sub init_models {
|
251 |
269 |
my ($self) = @_;
|
252 |
270 |
my $vc = $self->vc;
|
253 |
|
|
|
271 |
my $mode = $self->mode;
|
254 |
272 |
SL::Controller::Helper::GetModels->new(
|
255 |
273 |
controller => $self,
|
256 |
274 |
model => 'OrderItem',
|
... | ... | |
263 |
281 |
},
|
264 |
282 |
query => $self->delivery_plan_query,
|
265 |
283 |
with_objects => [ 'order', "order.$vc", 'part' ],
|
266 |
|
additional_url_params => { vc => $vc },
|
|
284 |
additional_url_params => { vc => $vc, mode => $mode},
|
267 |
285 |
);
|
268 |
286 |
}
|
269 |
287 |
|
... | ... | |
273 |
291 |
sub init_vc {
|
274 |
292 |
return $::form->{vc} if ($::form->{vc} eq 'customer' || $::form->{vc} eq 'vendor') || croak "self (DeliveryPlan) has no vc defined";
|
275 |
293 |
}
|
|
294 |
sub init_mode {
|
|
295 |
return $::form->{mode} if ($::form->{mode} eq 'delivery_value_report' || $::form->{mode} eq 'delivery_plan') || croak "self (DeliveryPlan) has no mode defined";
|
|
296 |
}
|
276 |
297 |
|
277 |
298 |
sub link_to {
|
278 |
299 |
my ($self, $object, %params) = @_;
|
Neuer Bericht: Lieferwertbericht
Erweiterung DeliveryPlan.pm um Modusweiche Lieferplan oder Lieferwertbericht
Implementierungstand Lieferwertbericht:
- Alle offenen Verkaufsaufträge werden berücksichtigt
- Beim CSV-Export wird die Einheit als Extra-Spalte exportiert und die
Einheiten bei allen anderen Spalten ausgeblendet
Ferner neues Recht Lieferwertbericht umgesetzt