Revision 8522a85e
Von Tamino Steinert vor mehr als 2 Jahren hinzugefügt
| SL/Controller/Reclamation.pm | ||
|---|---|---|
|   );
 | ||
| }
 | ||
|  | ||
| sub action_add_from_sales_invoice {
 | ||
|   my ($self) = @_;
 | ||
|  | ||
|   unless ($::form->{from_id}) {
 | ||
|     $self->js->flash('error', t8("Can't create new reclamation. No 'from_id' was given."));
 | ||
|     return $self->js->render();
 | ||
|   }
 | ||
|  | ||
|   require SL::DB::Invoice;
 | ||
|   my $invoice = SL::DB::Invoice->new(id => $::form->{from_id})->load;
 | ||
|   my $reclamation = $invoice->convert_to_reclamation();
 | ||
|  | ||
|   $self->reclamation($reclamation);
 | ||
|  | ||
|   $self->reinit_after_new_reclamation();
 | ||
|  | ||
|   $self->render(
 | ||
|     'reclamation/form',
 | ||
|     title => $self->get_title_for('add'),
 | ||
|     %{$self->{template_args}},
 | ||
|   );
 | ||
| }
 | ||
|  | ||
| sub action_add_from_purchase_invoice {
 | ||
|   my ($self) = @_;
 | ||
|  | ||
|   unless ($::form->{from_id}) {
 | ||
|     $self->js->flash('error', t8("Can't create new reclamation. No 'from_id' was given."));
 | ||
|     return $self->js->render();
 | ||
|   }
 | ||
|  | ||
|   require SL::DB::PurchaseInvoice;
 | ||
|   my $invoice = SL::DB::PurchaseInvoice->new(id => $::form->{from_id})->load;
 | ||
|   $invoice->{type} = $invoice->invoice_type; #can't add type → invoice_type in SL/DB/PurchaseInvoice
 | ||
|   my $reclamation = $invoice->convert_to_reclamation();
 | ||
|  | ||
|   $self->reclamation($reclamation);
 | ||
|  | ||
|   $self->reinit_after_new_reclamation();
 | ||
|  | ||
|   $self->render(
 | ||
|     'reclamation/form',
 | ||
|     title => $self->get_title_for('add'),
 | ||
|     %{$self->{template_args}},
 | ||
|   );
 | ||
| }
 | ||
|  | ||
| # edit an existing reclamation
 | ||
| sub action_edit {
 | ||
|   my ($self) = @_;
 | ||
| ... | ... | |
|     SL::DB::Reclamation
 | ||
|     SL::DB::Order
 | ||
|     SL::DB::DeliveryOrder
 | ||
|     SL::DB::Invoice
 | ||
|     SL::DB::PurchaseInvoice
 | ||
|   );
 | ||
|   my %allowed_linked_record_items = map {$_ => 1} qw(
 | ||
|     SL::DB::ReclamationItem
 | ||
|     SL::DB::OrderItem
 | ||
|     SL::DB::DeliveryOrderItem
 | ||
|     SL::DB::InvoiceItem
 | ||
|   );
 | ||
|  | ||
|   my $from_record_id = delete $::form->{converted_from_record_id};
 | ||
| SL/DB/Invoice.pm | ||
|---|---|---|
|   return $self->paid >= $self->amount;
 | ||
| }
 | ||
|  | ||
| sub convert_to_reclamation {
 | ||
|   my ($self, %params) = @_;
 | ||
|   $params{destination_type} = $self->is_sales ? 'sales_reclamation'
 | ||
|                                               : 'purchase_reclamation';
 | ||
|  | ||
|   require SL::DB::Reclamation;
 | ||
|   my $reclamation = SL::DB::Reclamation->new_from($self, %params);
 | ||
|  | ||
|   return $reclamation;
 | ||
| }
 | ||
|  | ||
| sub _clone_orderitem_delivery_order_item_cvar {
 | ||
|   my ($cvar) = @_;
 | ||
|  | ||
| SL/DB/PurchaseInvoice.pm | ||
|---|---|---|
|   join ' ', grep $_, map $_[0]->$_, qw(displayable_type record_number);
 | ||
| };
 | ||
|  | ||
| sub convert_to_reclamation {
 | ||
|   my ($self, %params) = @_;
 | ||
|   $params{destination_type} = $self->is_sales ? 'sales_reclamation'
 | ||
|                                               : 'purchase_reclamation';
 | ||
|  | ||
|   require SL::DB::Reclamation;
 | ||
|   my $reclamation = SL::DB::Reclamation->new_from($self, %params);
 | ||
|  | ||
|   return $reclamation;
 | ||
| }
 | ||
|  | ||
| sub create_ap_row {
 | ||
|   my ($self, %params) = @_;
 | ||
|   # needs chart as param
 | ||
| SL/DB/Reclamation.pm | ||
|---|---|---|
|     SL::DB::Reclamation
 | ||
|     SL::DB::Order
 | ||
|     SL::DB::DeliveryOrder
 | ||
|     SL::DB::Invoice
 | ||
|     SL::DB::PurchaseInvoice
 | ||
|   );
 | ||
|   unless( $allowed_sources{ref $source} ) {
 | ||
|     croak("Unsupported source object type '" . ref($source) . "'");
 | ||
| ... | ... | |
|     #Delivery Order
 | ||
|     { from => 'sales_delivery_order',    to => 'sales_reclamation',    abbr => 'sdsr', },
 | ||
|     { from => 'purchase_delivery_order', to => 'purchase_reclamation', abbr => 'pdpr', },
 | ||
|     #Invoice
 | ||
|     { from => 'invoice',                 to => 'sales_reclamation',    abbr => 'sisr', },
 | ||
|     { from => 'purchase_invoice',        to => 'purchase_reclamation', abbr => 'pipr', },
 | ||
|   );
 | ||
|   my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0];
 | ||
|   if (!$from_to) {
 | ||
| ... | ... | |
|     $record_args{contact_id} = $source->cp_id;
 | ||
|     $record_args{cv_record_number} = $source->cusordnumber;
 | ||
|     # }}} for vim folds
 | ||
|   } elsif ( $is_abbr_any->(qw(sisr)) ) { #Invoice(ar)
 | ||
|     map { $record_args{$_} = $source->$_ } # {{{ for vim folds
 | ||
|     qw(
 | ||
|       amount
 | ||
|       currency_id
 | ||
|       customer_id
 | ||
|       delivery_term_id
 | ||
|       department_id
 | ||
|       globalproject_id
 | ||
|       intnotes
 | ||
|       language_id
 | ||
|       netamount
 | ||
|       notes
 | ||
|       payment_id
 | ||
|       salesman_id
 | ||
|       shippingpoint
 | ||
|       shipvia
 | ||
|       tax_point
 | ||
|       taxincluded
 | ||
|       taxzone_id
 | ||
|       transaction_description
 | ||
|     );
 | ||
|     $record_args{contact_id} = $source->cp_id;
 | ||
|     $record_args{cv_record_number} = $source->cusordnumber;
 | ||
|     # }}} for vim folds
 | ||
|   } elsif ( $is_abbr_any->(qw(pipr)) ) { #Invoice(ap)
 | ||
|     map { $record_args{$_} = $source->$_ } # {{{ for vim folds
 | ||
|     qw(
 | ||
|       amount
 | ||
|       currency_id
 | ||
|       delivery_term_id
 | ||
|       department_id
 | ||
|       globalproject_id
 | ||
|       intnotes
 | ||
|       language_id
 | ||
|       netamount
 | ||
|       notes
 | ||
|       payment_id
 | ||
|       shipvia
 | ||
|       tax_point
 | ||
|       taxincluded
 | ||
|       taxzone_id
 | ||
|       transaction_description
 | ||
|       vendor_id
 | ||
|     );
 | ||
|     $record_args{contact_id} = $source->cp_id;
 | ||
|     # }}} for vim folds
 | ||
|   }
 | ||
|  | ||
|   if ( ($from_to->{from} =~ m{sales}) && ($from_to->{to} =~ m{purchase}) ) {
 | ||
| SL/DB/ReclamationItem.pm | ||
|---|---|---|
|       SL::DB::ReclamationItem
 | ||
|       SL::DB::OrderItem
 | ||
|       SL::DB::DeliveryOrderItem
 | ||
|       SL::DB::InvoiceItem
 | ||
|     )
 | ||
|   ) {
 | ||
|     croak("Unsupported source object type '" . ref($source) . "'");
 | ||
| ... | ... | |
|       pricegroup_id project_id qty reqdate sellprice serialnumber unit
 | ||
|     );
 | ||
|     $item_args{custom_variables} = \@custom_variables;
 | ||
|   } elsif (ref($source) eq 'SL::DB::InvoiceItem') {
 | ||
|     map { $item_args{$_} = $source->$_ } qw(
 | ||
|       active_discount_source active_price_source base_qty description discount
 | ||
|       lastcost longdescription parts_id position price_factor price_factor_id
 | ||
|       pricegroup_id project_id qty sellprice serialnumber unit
 | ||
|     );
 | ||
|     $item_args{custom_variables} = \@custom_variables;
 | ||
|   }
 | ||
|  | ||
|   my $item = $class->new(%item_args);
 | ||
| bin/mozilla/io.pl | ||
|---|---|---|
|   quotation();
 | ||
| }
 | ||
|  | ||
| sub sales_reclamation {
 | ||
|   my $id = $::form->{id};
 | ||
|  | ||
|   require SL::Controller::Reclamation;
 | ||
|   my $c = SL::Controller::Reclamation->new();
 | ||
|   $c->redirect_to(
 | ||
|     controller => 'Reclamation',
 | ||
|     action => 'add_from_sales_invoice',
 | ||
|     from_id => $id,
 | ||
|     type => 'sales_reclamation',
 | ||
|   );
 | ||
| }
 | ||
|  | ||
| sub purchase_reclamation {
 | ||
|   my $id = $::form->{id};
 | ||
|  | ||
|   require SL::Controller::Reclamation;
 | ||
|   my $c = SL::Controller::Reclamation->new();
 | ||
|   $c->redirect_to(
 | ||
|     controller => 'Reclamation',
 | ||
|     action => 'add_from_purchase_invoice',
 | ||
|     from_id => $id,
 | ||
|     type => 'purchase_reclamation',
 | ||
|   );
 | ||
| }
 | ||
|  | ||
| sub print_options {
 | ||
|   $::lxdebug->enter_sub();
 | ||
|  | ||
| bin/mozilla/ir.pl | ||
|---|---|---|
|                     : !$form->{id}      ? t8('This invoice has not been posted yet.')
 | ||
|                     :                     undef,
 | ||
|         ],
 | ||
|         action => [
 | ||
|           t8('Reclamation'),
 | ||
|           submit   => ['#form', { action => "purchase_reclamation" }], # can't call Reclamation directly
 | ||
|           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
 | ||
|           only_if   => ($::form->{type} eq 'purchase_invoice')
 | ||
|         ],
 | ||
|        ], # end of combobox "Workflow"
 | ||
|  | ||
|       combobox => [
 | ||
| bin/mozilla/is.pl | ||
|---|---|---|
|           checks   => [ 'kivi.validate_form' ],
 | ||
|           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
 | ||
|         ],
 | ||
|         action => [
 | ||
|           t8('Reclamation'),
 | ||
|           submit   => ['#form', { action => "sales_reclamation" }], # can't call Reclamation directly
 | ||
|           disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
 | ||
|           only_if   => ($::form->{type} eq 'invoice')
 | ||
|         ],
 | ||
|       ], # end of combobox "Workflow"
 | ||
|  | ||
|       combobox => [
 | ||
Auch abrufbar als: Unified diff
Workflow: (sales/purchase) invoice → reclamation