Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f5b56d67

Von Jan Büren vor etwa 10 Jahren hinzugefügt

  • ID f5b56d67c1ef6dc87d4dcd50ba31f9a2b0a20846
  • Vorgänger 4ecb8321
  • Nachfolger 38044b51

Einkaufs-Lieferplan

Lieferplan für noch nicht vollständig gelieferte Einkaufsaufträge.

Unterschiede anzeigen:

SL/Controller/DeliveryPlan.pm
22 22
  partnumber        => t8('Part Number'),
23 23
  qty               => t8('Qty'),
24 24
  shipped_qty       => t8('shipped'),
25
  delivered_qty     => t8('transferred out'),
25
  delivered_qty     => t8('transferred in / out'),
26 26
  not_shipped_qty   => t8('not shipped'),
27 27
  ordnumber         => t8('Order'),
28 28
  customer          => t8('Customer'),
29
  vendor            => t8('Vendor'),
29 30
  value_of_goods    => t8('Value of goods'),
30 31
);
31 32

  
33
my $vc;
34

  
32 35
sub action_list {
33 36
  my ($self) = @_;
34 37

  
38
  $vc = "customer";
39
  $self->make_filter_summary;
40
  $self->prepare_report;
41

  
42
  my $orderitems = $self->models->get;
43

  
44
  $self->report_generator_list_objects(report => $self->{report}, objects => $orderitems);
45
}
46

  
47
sub action_list_ap {
48
  my ($self) = @_;
49

  
50
  $vc = "vendor";
35 51
  $self->make_filter_summary;
36 52
  $self->prepare_report;
37 53

  
......
63 79
    delivered_qty     => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->delivered_qty, 2) . ' ' . $_[0]->unit } },
64 80
    ordnumber         => {      sub => sub { $_[0]->order->ordnumber                                                         },
65 81
                           obj_link => sub { $self->link_to($_[0]->order)                                                    } },
66
    customer          => {      sub => sub { $_[0]->order->customer->name                                                    },
67
                           obj_link => sub { $self->link_to($_[0]->order->customer)                                          } },
82
    $vc               => {      sub => sub { $_[0]->order->$vc->name                                                    },
83
                           obj_link => sub { $self->link_to($_[0]->order->$vc)                                          } },
68 84
  );
69 85

  
70 86
  # add value of goods in report
......
77 93
    std_column_visibility => 1,
78 94
    controller_class      => 'DeliveryPlan',
79 95
    output_format         => 'HTML',
80
    top_info_text         => $::locale->text('Delivery Plan for currently outstanding sales orders'),
96
    top_info_text         => ($vc eq 'customer') ? $::locale->text('Delivery Plan for currently outstanding sales orders') :
97
                                                   $::locale->text('Delivery Plan for currently outstanding purchase orders'),
81 98
    title                 => $::locale->text('Delivery Plan'),
82 99
    allow_pdf_export      => 1,
83 100
    allow_csv_export      => 1,
......
90 107
  $self->models->finalize; # for filter laundering
91 108
  $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
92 109
  $report->set_options(
93
    raw_top_info_text     => $self->render('delivery_plan/report_top',    { output => 0 }),
110
    raw_top_info_text     => $self->render('delivery_plan/report_top',    { output => 0 }, vc => $vc),
94 111
    raw_bottom_info_text  => $self->render('delivery_plan/report_bottom', { output => 0 }, models => $self->models),
95 112
  );
96 113
}
......
108 125
    [ $filter->{"reqdate:date::ge"},                              $::locale->text('Delivery Date') . " " . $::locale->text('From Date') ],
109 126
    [ $filter->{"reqdate:date::le"},                              $::locale->text('Delivery Date') . " " . $::locale->text('To Date')   ],
110 127
    [ $filter->{"qty:number"},                                    $::locale->text('Quantity')                                           ],
111
    [ $filter->{order}{customer}{"name:substr::ilike"},           $::locale->text('Customer')                                           ],
112
    [ $filter->{order}{customer}{"customernumber:substr::ilike"}, $::locale->text('Customer Number')                                    ],
128
    [ $filter->{order}{$vc}{"name:substr::ilike"},                ($vc eq 'customer') ? $::locale->text('Customer') : $::locale->text('Vendor')   ],
129
    [ $filter->{order}{$vc}{"${vc}number:substr::ilike"},         ($vc eq 'customer') ? $::locale->text('Customer Number') : $::locale->text('Vendor Number') ],
113 130
  );
114 131

  
115 132
  my %flags = (
......
131 148

  
132 149
sub delivery_plan_query {
133 150
  my $employee_id = SL::DB::Manager::Employee->current->id;
134
  my $oe_owner = $_[0]->all_edit_right ? '' : " oe.eployee_id = $employee_id AND";
151
  my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND";
135 152
  # check delivered state for delivery_orders (transferred out) if enabled
136 153
  my $filter_delivered = $::instance_conf->get_delivery_plan_calculate_transferred_do  ?
137 154
      "AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : '';
138 155
  [
139
  'order.customer_id' => { gt => 0 },
156
  "order.${vc}_id" => { gt => 0 },
140 157
  'order.closed' => 0,
141 158
  or => [ 'order.quotation' => 0, 'order.quotation' => undef ],
142 159

  
......
152 169
        FROM orderitems oi, oe, record_links rl, delivery_order_items doi
153 170
        WHERE
154 171
          oe.id = oi.trans_id AND
155
          oe.customer_id IS NOT NULL AND
172
          oe.${vc}_id IS NOT NULL AND
156 173
          (oe.quotation = 'f' OR oe.quotation IS NULL) AND
157 174
          NOT oe.closed AND
158 175
          $oe_owner
......
176 193
    SELECT oi.id FROM orderitems oi, oe
177 194
    WHERE
178 195
      oe.id = oi.trans_id AND
179
      oe.customer_id IS NOT NULL AND
196
      oe.${vc}_id IS NOT NULL AND
180 197
      (oe.quotation = 'f' OR oe.quotation IS NULL) AND
181 198
      NOT oe.closed AND
182 199
      $oe_owner
......
211 228
          rl.from_table = 'oe' AND
212 229
          rl.to_table = 'delivery_orders' AND
213 230

  
214
          oe.customer_id IS NOT NULL AND
231
          oe.${vc}_id IS NOT NULL AND
215 232
          $oe_owner
216 233
          (oe.quotation = 'f' OR oe.quotation IS NULL) AND NOT oe.closed
217 234
      ) rl
......
228 245
        WHERE oi.trans_id = rl.from_id AND rl.from_table = 'oe' AND rl.to_table = 'delivery_orders'
229 246
      ) AND
230 247
      coalesce(sum, 0) < oi.qty AND
231
      oe.customer_id IS NOT NULL AND
248
      oe.${vc}_id IS NOT NULL AND
232 249
      $oe_owner
233 250
      (oe.quotation = 'f' OR oe.quotation IS NULL) AND NOT oe.closed
234 251
  " ],
......
249 266
      %sort_columns,
250 267
    },
251 268
    query        => $self->delivery_plan_query,
252
    with_objects => [ 'order', 'order.customer', 'part' ],
269
    with_objects => [ 'order', "order.$vc", 'part' ],
253 270
  );
254 271
}
255 272

  

Auch abrufbar als: Unified diff