Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision bcdeb6ec

Von Tamino Steinert vor fast 2 Jahren hinzugefügt

  • ID bcdeb6ecdf8f6bdd981167ffb0a3dafcc4408eb5
  • Vorgänger a6c54e9f
  • Nachfolger c389a0e6

Workflow: (sales/purchase) invoice → reclamation

Unterschiede anzeigen:

SL/Controller/Reclamation.pm
146 146
  );
147 147
}
148 148

  
149
sub action_add_from_sales_invoice {
150
  my ($self) = @_;
151

  
152
  unless ($::form->{from_id}) {
153
    $self->js->flash('error', t8("Can't create new reclamation. No 'from_id' was given."));
154
    return $self->js->render();
155
  }
156

  
157
  require SL::DB::Invoice;
158
  my $invoice = SL::DB::Invoice->new(id => $::form->{from_id})->load;
159
  my $reclamation = $invoice->convert_to_reclamation();
160

  
161
  $self->reclamation($reclamation);
162

  
163
  $self->reinit_after_new_reclamation();
164

  
165
  $self->render(
166
    'reclamation/form',
167
    title => $self->get_title_for('add'),
168
    %{$self->{template_args}},
169
  );
170
}
171

  
172
sub action_add_from_purchase_invoice {
173
  my ($self) = @_;
174

  
175
  unless ($::form->{from_id}) {
176
    $self->js->flash('error', t8("Can't create new reclamation. No 'from_id' was given."));
177
    return $self->js->render();
178
  }
179

  
180
  require SL::DB::PurchaseInvoice;
181
  my $invoice = SL::DB::PurchaseInvoice->new(id => $::form->{from_id})->load;
182
  $invoice->{type} = $invoice->invoice_type; #can't add type → invoice_type in SL/DB/PurchaseInvoice
183
  my $reclamation = $invoice->convert_to_reclamation();
184

  
185
  $self->reclamation($reclamation);
186

  
187
  $self->reinit_after_new_reclamation();
188

  
189
  $self->render(
190
    'reclamation/form',
191
    title => $self->get_title_for('add'),
192
    %{$self->{template_args}},
193
  );
194
}
195

  
149 196
# edit an existing reclamation
150 197
sub action_edit {
151 198
  my ($self) = @_;
......
1658 1705
    SL::DB::Reclamation
1659 1706
    SL::DB::Order
1660 1707
    SL::DB::DeliveryOrder
1708
    SL::DB::Invoice
1709
    SL::DB::PurchaseInvoice
1661 1710
  );
1662 1711
  my %allowed_linked_record_items = map {$_ => 1} qw(
1663 1712
    SL::DB::ReclamationItem
1664 1713
    SL::DB::OrderItem
1665 1714
    SL::DB::DeliveryOrderItem
1715
    SL::DB::InvoiceItem
1666 1716
  );
1667 1717

  
1668 1718
  my $from_record_id = delete $::form->{converted_from_record_id};
SL/DB/Invoice.pm
137 137
  return $self->paid >= $self->amount;
138 138
}
139 139

  
140
sub convert_to_reclamation {
141
  my ($self, %params) = @_;
142
  $params{destination_type} = $self->is_sales ? 'sales_reclamation'
143
                                              : 'purchase_reclamation';
144

  
145
  require SL::DB::Reclamation;
146
  my $reclamation = SL::DB::Reclamation->new_from($self, %params);
147

  
148
  return $reclamation;
149
}
150

  
140 151
sub _clone_orderitem_delivery_order_item_cvar {
141 152
  my ($cvar) = @_;
142 153

  
SL/DB/PurchaseInvoice.pm
124 124
  join ' ', grep $_, map $_[0]->$_, qw(displayable_type record_number);
125 125
};
126 126

  
127
sub convert_to_reclamation {
128
  my ($self, %params) = @_;
129
  $params{destination_type} = $self->is_sales ? 'sales_reclamation'
130
                                              : 'purchase_reclamation';
131

  
132
  require SL::DB::Reclamation;
133
  my $reclamation = SL::DB::Reclamation->new_from($self, %params);
134

  
135
  return $reclamation;
136
}
137

  
127 138
sub create_ap_row {
128 139
  my ($self, %params) = @_;
129 140
  # needs chart as param
SL/DB/Reclamation.pm
258 258
    SL::DB::Reclamation
259 259
    SL::DB::Order
260 260
    SL::DB::DeliveryOrder
261
    SL::DB::Invoice
262
    SL::DB::PurchaseInvoice
261 263
  );
262 264
  unless( $allowed_sources{ref $source} ) {
263 265
    croak("Unsupported source object type '" . ref($source) . "'");
......
278 280
    #Delivery Order
279 281
    { from => 'sales_delivery_order',    to => 'sales_reclamation',    abbr => 'sdsr', },
280 282
    { from => 'purchase_delivery_order', to => 'purchase_reclamation', abbr => 'pdpr', },
283
    #Invoice
284
    { from => 'invoice',                 to => 'sales_reclamation',    abbr => 'sisr', },
285
    { from => 'purchase_invoice',        to => 'purchase_reclamation', abbr => 'pipr', },
281 286
  );
282 287
  my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0];
283 288
  if (!$from_to) {
......
373 378
    $record_args{contact_id} = $source->cp_id;
374 379
    $record_args{cv_record_number} = $source->cusordnumber;
375 380
    # }}} for vim folds
381
  } elsif ( $is_abbr_any->(qw(sisr)) ) { #Invoice(ar)
382
    map { $record_args{$_} = $source->$_ } # {{{ for vim folds
383
    qw(
384
      amount
385
      currency_id
386
      customer_id
387
      delivery_term_id
388
      department_id
389
      globalproject_id
390
      intnotes
391
      language_id
392
      netamount
393
      notes
394
      payment_id
395
      salesman_id
396
      shippingpoint
397
      shipvia
398
      tax_point
399
      taxincluded
400
      taxzone_id
401
      transaction_description
402
    );
403
    $record_args{contact_id} = $source->cp_id;
404
    $record_args{cv_record_number} = $source->cusordnumber;
405
    # }}} for vim folds
406
  } elsif ( $is_abbr_any->(qw(pipr)) ) { #Invoice(ap)
407
    map { $record_args{$_} = $source->$_ } # {{{ for vim folds
408
    qw(
409
      amount
410
      currency_id
411
      delivery_term_id
412
      department_id
413
      globalproject_id
414
      intnotes
415
      language_id
416
      netamount
417
      notes
418
      payment_id
419
      shipvia
420
      tax_point
421
      taxincluded
422
      taxzone_id
423
      transaction_description
424
      vendor_id
425
    );
426
    $record_args{contact_id} = $source->cp_id;
427
    # }}} for vim folds
376 428
  }
377 429

  
378 430
  if ( ($from_to->{from} =~ m{sales}) && ($from_to->{to} =~ m{purchase}) ) {
SL/DB/ReclamationItem.pm
55 55
      SL::DB::ReclamationItem
56 56
      SL::DB::OrderItem
57 57
      SL::DB::DeliveryOrderItem
58
      SL::DB::InvoiceItem
58 59
    )
59 60
  ) {
60 61
    croak("Unsupported source object type '" . ref($source) . "'");
......
86 87
      pricegroup_id project_id qty reqdate sellprice serialnumber unit
87 88
    );
88 89
    $item_args{custom_variables} = \@custom_variables;
90
  } elsif (ref($source) eq 'SL::DB::InvoiceItem') {
91
    map { $item_args{$_} = $source->$_ } qw(
92
      active_discount_source active_price_source base_qty description discount
93
      lastcost longdescription parts_id position price_factor price_factor_id
94
      pricegroup_id project_id qty sellprice serialnumber unit
95
    );
96
    $item_args{custom_variables} = \@custom_variables;
89 97
  }
90 98

  
91 99
  my $item = $class->new(%item_args);
bin/mozilla/io.pl
1109 1109
  quotation();
1110 1110
}
1111 1111

  
1112
sub sales_reclamation {
1113
  my $id = $::form->{id};
1114

  
1115
  require SL::Controller::Reclamation;
1116
  my $c = SL::Controller::Reclamation->new();
1117
  $c->redirect_to(
1118
    controller => 'Reclamation',
1119
    action => 'add_from_sales_invoice',
1120
    from_id => $id,
1121
    type => 'sales_reclamation',
1122
  );
1123
}
1124

  
1125
sub purchase_reclamation {
1126
  my $id = $::form->{id};
1127

  
1128
  require SL::Controller::Reclamation;
1129
  my $c = SL::Controller::Reclamation->new();
1130
  $c->redirect_to(
1131
    controller => 'Reclamation',
1132
    action => 'add_from_purchase_invoice',
1133
    from_id => $id,
1134
    type => 'purchase_reclamation',
1135
  );
1136
}
1137

  
1112 1138
sub print_options {
1113 1139
  $::lxdebug->enter_sub();
1114 1140

  
bin/mozilla/ir.pl
370 370
                    : !$form->{id}      ? t8('This invoice has not been posted yet.')
371 371
                    :                     undef,
372 372
        ],
373
        action => [
374
          t8('Reclamation'),
375
          submit   => ['#form', { action => "purchase_reclamation" }], # can't call Reclamation directly
376
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
377
          only_if   => ($::form->{type} eq 'purchase_invoice')
378
        ],
373 379
       ], # end of combobox "Workflow"
374 380

  
375 381
      combobox => [
bin/mozilla/is.pl
474 474
          checks   => [ 'kivi.validate_form' ],
475 475
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
476 476
        ],
477
        action => [
478
          t8('Reclamation'),
479
          submit   => ['#form', { action => "sales_reclamation" }], # can't call Reclamation directly
480
          disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
481
          only_if   => ($::form->{type} eq 'invoice')
482
        ],
477 483
      ], # end of combobox "Workflow"
478 484

  
479 485
      combobox => [

Auch abrufbar als: Unified diff