Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9595b914

Von Kivitendo Admin vor etwa 1 Jahr hinzugefügt

  • ID 9595b9142eab282a6bf89d8c1eeb17f6eab08ae6
  • Vorgänger 49dd3021
  • Nachfolger 9d5ccb64

SL::Dev::Record - Verkaufsangebote erstellen per create_sales_quotation

Dafür eine verallgemeinerte Hilfsfunktion erstellt, die sowohl Angebot
als auch Auftrag kann.

Unterschiede anzeigen:

SL/Dev/Record.pm
11 11
                    create_invoice_item
12 12
                    create_reclamation_item
13 13

  
14
                    create_sales_quotation
14 15
                    create_sales_order
15 16
                    create_sales_delivery_order
16 17
                    create_sales_invoice
......
48 49
                                 purchase_invoice     => 'SL::DB::InvoiceItem',
49 50
                                 credit_note          => 'SL::DB::InvoiceItem',
50 51
                                 sales_order          => 'SL::DB::OrderItem',
52
                                 sales_quotation      => 'SL::DB::OrderItem',
51 53
                                 purchase_order       => 'SL::DB::OrderItem',
52 54
                                 sales_delivery_order => 'SL::DB::DeliveryOrderItem',
53 55
                                 purchase_delivery_order => 'SL::DB::DeliveryOrderItem',
......
206 208
  return $delivery_order;
207 209
}
208 210

  
209
sub create_sales_order {
211
sub create_sales_quotation {
210 212
  my (%params) = @_;
213
  $params{type} = 'sales_quotation';
214
  _create_sales_order_or_quotation(%params);
215
}
211 216

  
212
  my $record_type = 'sales_order';
213
  my $orderitems = delete $params{orderitems} // _create_two_items($record_type);
214
  _check_items($orderitems, $record_type);
215

  
216
  my $save = delete $params{save} // 0;
217

  
218
  my $customer = $params{customer} // new_customer(name => 'Testcustomer')->save;
219
  die "illegal customer" unless ref($customer) eq 'SL::DB::Customer';
220

  
221
  my $order = SL::DB::Order->new(
222
    customer_id  => delete $params{customer_id} // $customer->id,
223
    taxzone_id   => delete $params{taxzone_id}  // $customer->taxzone->id,
224
    currency_id  => delete $params{currency_id} // $::instance_conf->get_currency_id,
225
    taxincluded  => delete $params{taxincluded} // 0,
226
    employee_id  => delete $params{employee_id} // SL::DB::Manager::Employee->current->id,
227
    salesman_id  => delete $params{employee_id} // SL::DB::Manager::Employee->current->id,
228
    transdate    => delete $params{transdate}   // DateTime->today,
229
    orderitems   => $orderitems,
230
  );
231
  $order->assign_attributes(%params) if %params;
232

  
233
  if ( $save ) {
234
    $order->calculate_prices_and_taxes;
235
    $order->save;
236
  }
237
  return $order;
217
sub create_sales_order {
218
  my (%params) = @_;
219
  $params{type} = 'sales_order';
220
  _create_sales_order_or_quotation(%params);
238 221
}
239 222

  
240 223
sub create_purchase_order {
......
763 746
  return $gl_transaction;
764 747
}
765 748

  
749
sub _create_sales_order_or_quotation {
750
  my (%params) = @_;
751

  
752
  my $record_type = $params{type};
753
  die "illegal type" unless $record_type eq 'sales_order' or $record_type eq 'sales_quotation';
754

  
755
  my $orderitems = delete $params{orderitems} // _create_two_items($record_type);
756
  _check_items($orderitems, $record_type);
757

  
758
  my $save = delete $params{save} // 0;
759

  
760
  my $customer = $params{customer} // new_customer(name => 'Testcustomer')->save;
761
  die "illegal customer" unless ref($customer) eq 'SL::DB::Customer';
762

  
763
  my $record = SL::DB::Order->new(
764
    customer_id  => delete $params{customer_id} // $customer->id,
765
    taxzone_id   => delete $params{taxzone_id}  // $customer->taxzone->id,
766
    currency_id  => delete $params{currency_id} // $::instance_conf->get_currency_id,
767
    taxincluded  => delete $params{taxincluded} // 0,
768
    employee_id  => delete $params{employee_id} // SL::DB::Manager::Employee->current->id,
769
    salesman_id  => delete $params{employee_id} // SL::DB::Manager::Employee->current->id,
770
    transdate    => delete $params{transdate}   // DateTime->today,
771
    quotation    => $record_type eq 'sales_quotation' ? 1 : 0,
772
    orderitems   => $orderitems,
773
  );
774
  $record->assign_attributes(%params) if %params;
775

  
776
  if ( $save ) {
777
    $record->calculate_prices_and_taxes;
778
    $record->save;
779
  }
780
  return $record;
781
}
782

  
783

  
766 784
sub _transaction_tax_helper {
767 785
  # checks for hash-entries with key tax, tax_id or taxkey
768 786
  # returns an SL::DB::Tax object
......
902 920
    orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 1, sellprice => 9) ]
903 921
  ) for 1 .. 100;
904 922

  
923
=head2 C<create_sales_quotation %PARAMS>
924

  
925
See C<create_sales_order>
926

  
905 927
=head2 C<create_purchase_order %PARAMS>
906 928

  
907 929
See comments for C<create_sales_order>.

Auch abrufbar als: Unified diff